`
yaojingguo
  • 浏览: 212471 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

The New C: X Macros (memo)

 
阅读更多

The code:

#include <stdio.h>

#define COLOR_TABLE \
X(red, "red")       \
X(green, "green")   \
X(blue, "blue")

#define X(a, b) a,
enum COLOR {
  COLOR_TABLE
};
#undef X

#define X(a, b) b,
char *color_name[] = {
  COLOR_TABLE
};
#undef X

int main() {
  enum COLOR c = red;
  printf("c=%s\n", color_name[c]);
  return 0;
}
 

Refer to http://www.drdobbs.com/cpp/184401387

分享到:
评论

相关推荐

    ehlib_vcl_src_9_3.26

    To install a new version of the library in the IDE, use the installation program .\Installer\EhLibInstaller.exe If, at the installation have any problems, write a letter to ehlib support address ...

    EhLib 9.1.024

    To install a new version of the library in the IDE, use the installation program .\Installer\EhLibInstaller.exe If, at the installation have any problems, write a letter to ehlib support address ...

    RxLib控件包内含RxGIF,全部源码及DEMO

    It supports macros in the SQL text, which are similar to Params. Macros allow to change query text easily and handy. TSQLScript allows multiple SQL statements in one query. TRxDBFilter encapsulates...

    EhLib5.0.13 最新的ehlib源码

    Copy files from Common and Delphi[X] | BDS2006 directories of the EhLib archive to 'EhLib directory'. By default Delphi (5, 6 and 7) places compiled files to the &lt;Delphi path&gt;\Projects\Bpl ...

    EhLib 8.0 Build 8.0.023 Pro Edition FullSource for D7-XE8

    To install a new version of the library in the IDE, use the installation program in .\Installer\EhLibInstaller.exe Overview -------- The Library contains several components and objects. TDBGridEh...

    EhLib 6.3 Build 6.3.176 Russian version. Full source included.

    To install a new version of the library in the IDE, use the installation program in .\Installer\EhLibInstaller.exe Overview -------- The Library contains several components and objects. TDBGridEh...

    FastReport.v4.15 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版支持D4-XE5

    + added support of Embarcadero Rad Studio EX2 (x32/x64) + added export of Excel formulas in the BIFF export + added export of external URLs in the PDF export + added converter from Rave Reports ...

Global site tag (gtag.js) - Google Analytics