My current code is:
int my_func(int a)
{
#ifdef _WIN32
return _func(a);
#else
return func(a);
#endif
}
But I think it would be better if it was something like:
#ifdef _WIN32
#define common_func(a) _func(a);
#else
#define common_func(a) func(a);
#endif
int my_func(int a)
{
return common_func(a);
}
Now, I have never done this and I don't know what I am doing. The K&R cat() example is confusing. I basically just want to get the #ifdef
s out of the function because it would get too messy because I have to run the function several times.
func()
and _func()
are the same function, just Windows thought it would be a great idea to prepend it with an underscore. So it's not even a macro function but more like a function alias maybe. Or a wrapper?
Does this impact performance? Does the generated code differ from version 1? Is there some trick, since the difference is just the underscore?
I want to do it correctly and properly. Please help.