Gcc -D option not to do what I thought it would be

I am trying to use AsmJit in a project. This is the makefile I used:

CC = g++ CFLAGS = -D ASMJIT_API -I dep/ test: src/main.cpp $(CC) $(CFLAGS) src/main.cpp -o test.exe 

I had compiler errors when trying this, so instead I uncommented the #define ASMJIT_API line from dep / AsmJit / Config.h and removed the -D switch from the makefile and everything that was compiled. I am using gcc 4.5.3. Any ideas?

Thanks.

EDIT: compiler errors

 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 
+6
source share
2 answers

There is a difference between #define ASMJIT_API and -DASMJIT_API .

The #define defines ASMJIT_API as nothing, and the -D flag defines the preprocessor constant as 1 .

Using the -D flag, line 274 build.h expands to

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

causes a compiler error.

+6
source

Do not insert a space between -D and ASMJIT_API. The same for -I

 CFLAGS = -DASMJIT_API -Idep/ 

There you go.

0
source

Source: https://habr.com/ru/post/909867/


All Articles