How to write a macro to concatenate two symbols without spaces between them?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

Here is my code
---------------------------------------
#define TYPE  1x1
void func_1x1() { ... }
void func_2x2() { ... }
void func_3x3() { ... }
---------------------------------------

I want to implement such an macro my_func(), which asscociats with the
corresponding function automatically
according to the value of another macro TYPE.  For example, if TYPE is 1x1
my_func() is expanded to func_1x1()
and if TYPE is 2x2, my_func() is expanded to func_2x2()
I tried #define my_func func ## TYPE
and #define my_func func TYPE. They are not appropriate.
How should I write this macro my_func()?

Best Regard
--------------
PRC
Oct 31, 2008

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux