1st problem: Is it possible to call a function with some parameters, and after compilation it can be changed before compilation either during preprocessing or during compilation into something like
Some might wonder why such a need arose.
In fact, I am porting code in windows using visual studio 2010, and there are some functions that are deprecated like strcpy (), strcat (), etc. Instead, it uses strcpy_s () instead.
I know that I could suppress it with #pragma disable(warning: ) or by providing flags like:
_CRT_NONSTDC_NO_DEPRRECATE _CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS
But I do not want to ignore or suppress them.
I tried just replacing the string instead of ignoring using:
#define strcpy strcpy_s
as here http://msdn.microsoft.com/en-us/library/td1esda9.aspx I read that there will be no inconsistency of the arguments if I did not provide the second argument.
I mean this should be fine if I use like this:
#define strcpy strcpy_s strcpy(dest,src);
But he is not. It still raises a warning.
Definition of strcpy_s:
errno_t strcpy_s( char *strDestination, size_t numberOfElements, const char *strSource );
Second problem: The first argument is a pointer to dynamically allocated memory, since I can get the size of memory indicated by this pointer. Although I read that this is not possible, there must be some way (hopefully).
By the way, what is _countof(var) ?