6

I'm trying to use AsmJit in a project. This is the makefile I was using:

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

test: src/main.cpp
        $(CC) $(CFLAGS) src/main.cpp -o test.exe

I was getting compiler errors when trying this, so instead I uncommented the line #define ASMJIT_API from dep/AsmJit/Config.h, and removed the -D switch from the makefile and everything compiled cleanly. I'm 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
auselen
  • 27,577
  • 7
  • 73
  • 114
flumpb
  • 1,707
  • 3
  • 16
  • 33
  • What compiler errors are you getting? – makes Mar 03 '12 at 02:04
  • Basically errors pointing to the fact that something isn't defined correctly. When #define ASMJIT_API is set those other defines work as intended. I'll edit my post to include them if they help at all. – flumpb Mar 03 '12 at 02:05
  • yes, that would help if you posted more code. – selbie Mar 03 '12 at 02:13
  • Well, what's going on at dep/Asmjit/Build.h, line 274 ? – selbie Mar 03 '12 at 02:15
  • ASMJIT_API void asertionFailure(const char* file, int line, const char* exp); – flumpb Mar 03 '12 at 02:19
  • Go look at the pre-processor output with the -E option. "g++ -E -DASMJIT_API -Idep/ src/main.cpp" Now go look at the line in the output where "assertionFailure" failure is declared. Did ASMJIT_API get translated to a number? What about the line above it? – selbie Mar 03 '12 at 02:27
  • @selbie: That -E option will be excellent for the future. Thanks, and I appreciate your continued help on this matter. – flumpb Mar 03 '12 at 02:32

2 Answers2

6

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

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

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

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

causing the compiler error.

makes
  • 6,438
  • 3
  • 40
  • 58
0

Don't insert a space between -D and ASMJIT_API. Ditto for -I

CFLAGS = -DASMJIT_API -Idep/

There you go.

selbie
  • 100,020
  • 15
  • 103
  • 173
  • @kisplit - When you type "make test", do you see the -DASMJIT_API as part of the generated command line? – selbie Mar 03 '12 at 02:11