Put together function name from type in macro
Hi!
I'm doing some experimentation with C and trying some stuff out.
Right now I am playing around with macros and I found the GCC typeof keyword which I found intriging.
Anyway so I am trying to make a "initializer" macro which will more or less take any type of structure and call it's "construct function"
More or less something like this:
Code:
SomeType foo;
construct( foo ); // Becomes -> SomeType_Construct( &foo );
Though I am having problem with pasting together the type and the _Construct and is wondering if anyone else know what to do or got a better idea?
Doing this doesn't work as it tries to construct this string: typeof( object )_Construct( &object )
Code:
#define construct( object ) typeof( object )##_Construct( &object )
If you got a better way you know to solve the same problem then of course I am interested in that as well.