I'm getting weird errors trying to build libcpu on Mac OS X 10.7. Does anyone have an idea what this could be caused by? My guess is the CMake file somewhere causes __STDC_FORMAT_MACROS to be defined wrongly ... ?
I googled for that constant, but my google-fu is weak, it seems. Lots of other-project-specific issues and fixes, but nothing what it really does. And the inttypes.h header doesn't mention what it's for either.
Thanks for any google search terms, hints and suggestions any of you would want to supply. Here's the log:
thestarsmydestination:libcpu uli$ make
[ 0%] [ 0%] Building CXX object arch/6502/CMakeFiles/6502.dir/6502_arch.cpp.o
Building CXX object arch/fapra/CMakeFiles/fapra.dir/fapra_disasm.cpp.o
<command-line>: error: "__STDC_FORMAT_MACROS" redefined
<command-line>: error: this is the location of the previous definition
<command-line>: error: "__STDC_FORMAT_MACROS" redefined
<command-line>: error: this is the location of the previous definition
make[3]: *** [arch/fapra/CMakeFiles/fapra.dir/fapra_disasm.cpp.o] Error 1
make[2]: *** [arch/fapra/CMakeFiles/fapra.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
make[3]: *** [arch/6502/CMakeFiles/6502.dir/6502_arch.cpp.o] Error 1
make[3]: *** Waiting for unfinished jobs....
[ 1%] Building CXX object arch/6502/CMakeFiles/6502.dir/6502_disasm.cpp.o
<command-line>: error: "__STDC_FORMAT_MACROS" redefined
<command-line>: error: this is the location of the previous definition
make[3]: *** [arch/6502/CMakeFiles/6502.dir/6502_disasm.cpp.o] Error 1
make[2]: *** [arch/6502/CMakeFiles/6502.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
Dunno why we define it. Does something like this fix it for you?
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bc2353c..721cf2f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -72,7 +72,7 @@ ENDMACRO(TARGET_LINK_LLVM)
# Add extra warnings for gcc/g++.
#
IF(CMAKE_COMPILER_IS_GNUCXX)
- ADD_DEFINITIONS(-W -Wall -Wextra -Wno-unused -Werror
-D__STDC_FORMAT_MACROS=1)
+ ADD_DEFINITIONS(-W -Wall -Wextra -Wno-unused -Werror)
ENDIF()
FOREACH(ARCHITECTURE ${GUEST_ARCHITECTURES})
It gets me back to an error where it's looking for the wrong LLVM version, but that may be something I did in earlier attempts.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
It turns out I added __STDC_FORMAT_MACROS:
https://github.com/libcpu/libcpu/commit/eb320a5a00f47377caf7771c4779529555b83819
which seems to be required to use <inttypes.h> in C++ code on Linux. I
verified that on Ubuntu just now. Does the attached patch help?
Pekka
Oh well, my patch doesn't seem to work on Linux, so no point in trying it out.
What compiler are you using, btw? Is this Xcode 4.2 or later? If so,
you should probably see if adding these options help:
-std=c++0x -stdlib=libc++ -U__STRICT_ANSI__ -D__STDC_FORMAT_MACROS
As suggested in http://libcxx.llvm.org/
Pekka