在i包括其中使用由多个头文件我得到联误差在头文件中的“xmacro.h”:X-宏重定义
Error LNK2005: "char const * * iD_Strings" ([email protected]@3PAPBDA) already defined in header_file.obj
1.//"xmacro.h"
2.
3.// (1) Define code generating macro
4.
5. #ifndef XMACRO_H
6. #define XMACRO_H
7.
8. #define GENERATE_IDS \
9. X(_Name, "/Name") \
10. X(_ID, "/ID")
11.
12. // (2) Define X-Macro for generating enum members
13.
14. #define X(id, idString) id,
15. enum IDs
16. {
17. ID_LOWERBOUND = -1,
18. GENERATE_IDS
19. NUM_IDS
20. };
21. #undef X
22.
23. // (3) Define X-Macro for generating string names
24.
25. #define X(id, idString) idString,
26. const char* iD_Strings[] =
27. {
28. GENERATE_IDS
29. NULL
30. };
31. #undef X
32.
33. #endif
它产生时,我限定X-错误用于在第23行生成字符串名称的宏。我将如何使用单个宏而不重新定义它?
的确,我设法误读了那个。 – 2010-02-02 23:47:01