Hello,
I have an option of calling one of two functions from a library, say
blah_32f(parameters) or blah_64f(parameters)
Where blah can be any of a large number of functions and the number determines the data type (basically between float and double. I'd like to define a macro that would allow me to simply define it from compiler flags, so say:
#define IPS 32f or 64f conditionally
and call the function as :
blah_IPS(parameters)
Now, since the macro is not standalone, it is not being expanded, is there some way that I can force it's expansion? This is preferable to redefining all the possible functions I might call in this manner.
The best that I am aware that you could do is smth like this:
1 2 3 4 5 6 7 8 9
#define APPEND_EX(fname, suffix) (fname##_##suffix)
#define APPEND(fname, suffix) APPEND_EX(fname, suffix)
#define NUM 64
int main()
{
int identifier_64 = 5;
cout << APPEND(identifier, NUM); //turns into (identifier_64)
}
You can use it with functions and such. For what it's worth there are probably better pre-processors, although I doubt that is feasible. For example, look at gema: http://gema.sourceforge.net/new/index.shtml
I have no experience with it, other than to have browsed its docs. It appears very powerful, but is not Unicode enabled yet (and may not be soon).