gcc-D选项没有做我认为会做的事情

gcc-D选项没有做我认为会做的事情,gcc,makefile,asmjit,Gcc,Makefile,Asmjit,我正在尝试在项目中使用AsmJit。这是我使用的makefile: CC = g++ CFLAGS = -D ASMJIT_API -I dep/ test: src/main.cpp $(CC) $(CFLAGS) src/main.cpp -o test.exe 尝试此操作时,我遇到了编译器错误,因此我从dep/ASMJIT/Config.h中取消了行#define ASMJIT_API的注释,并从makefile中删除了-D开关,所有内容都被干净地编译。我使用的是GCC

我正在尝试在项目中使用AsmJit。这是我使用的makefile:

CC = g++
CFLAGS = -D ASMJIT_API -I dep/

test: src/main.cpp
        $(CC) $(CFLAGS) src/main.cpp -o test.exe
尝试此操作时,我遇到了编译器错误,因此我从dep/ASMJIT/Config.h中取消了行
#define ASMJIT_API
的注释,并从makefile中删除了-D开关,所有内容都被干净地编译。我使用的是GCC4.5.3。有什么想法吗

谢谢

编辑:编译器错误

g++ -DASMJIT_API -Idep/ src/main.cpp -o test.exe
In file included from dep/AsmJit/Assembler.h:31:0,
                 from src/main.cpp:1:
dep/AsmJit/Build.h:274:1: error: expected unqualified-id before numeric constant
In file included from dep/AsmJit/AssemblerX86X64.h:36:0,
                 from dep/AsmJit/Assembler.h:51,
                 from src/main.cpp:1:
dep/AsmJit/Defs.h:408:1: error: expected unqualified-id before numeric constant
In file included from dep/AsmJit/DefsX86X64.h:36:0,
                 from dep/AsmJit/Defs.h:423,
                 from dep/AsmJit/AssemblerX86X64.h:36,
                 from dep/AsmJit/Assembler.h:51,
                 from src/main.cpp:1:
dep/AsmJit/Util.h:412:8: error: expected identifier before numeric constant
dep/AsmJit/Util.h:412:8: error: expected unqualified-id before numeric constant
src/main.cpp:6:1: error: expected ‘}’ at end of input
makefile:5: recipe for target `test' failed
make: *** [test] Error 1

不要在-D和ASMJIT_API之间插入空格。我也一样

CFLAGS = -DASMJIT_API -Idep/

好了。

定义ASMJIT\u API和
-DASMJIT\u API
之间有区别

#define
语句将
ASMJIT_API
定义为nothing,而

使用
-D
标志,build.h的第274行扩展为

1 void assertionFailure(const char* file, int line, const char* exp);

导致编译器错误。

您遇到了哪些编译器错误?基本上是指某些内容定义不正确的错误。当设置了#define ASMJIT_API时,其他定义将按预期工作。如果它们有帮助的话,我会编辑我的帖子以包含它们。是的,如果你发布更多的代码,那会有帮助。那么,在dep/Asmjit/Build.h,第274行发生了什么?Asmjit\u API void asertionFailure(const char*file,int line,const char*exp)@kisplit-键入“maketest”时,是否将-DASMJIT_API视为生成的命令行的一部分?