在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