cJSON
cJSON copied to clipboard
Clang complains about lack of ansi compliance (use of long long) on OSX
On OSX using Clang, I get errors about long long not being a supported datatype in ansi C.
I am building through the following process
git clone https://github.com/DaveGamble/cJSON
cd cJSON
mkdir build
cd build
cmake ..
make
The full error message I receive is:
In file included from /Users/kennethcochran/programming/libsource/cJSON/tests/print_number.c:24:
In file included from /Users/kennethcochran/programming/libsource/cJSON/tests/unity/src/unity.h:16:
/Users/kennethcochran/programming/libsource/cJSON/tests/unity/src/unity_internals.h:73:10: error:
'long long' is an extension when C99 mode is not enabled [-Werror,-Wlong-long]
#if (UINTPTR_MAX <= 0xFFFF)
^
/usr/include/stdint.h:132:23: note: expanded from macro 'UINTPTR_MAX'
#define UINTPTR_MAX UINT64_MAX
^
/usr/include/stdint.h:87:27: note: expanded from macro 'UINT64_MAX'
#define UINT64_MAX 18446744073709551615ULL
^
In file included from /Users/kennethcochran/programming/libsource/cJSON/tests/print_number.c:24:
In file included from /Users/kennethcochran/programming/libsource/cJSON/tests/unity/src/unity.h:16:
/Users/kennethcochran/programming/libsource/cJSON/tests/unity/src/unity_internals.h:75:12: error:
'long long' is an extension when C99 mode is not enabled [-Werror,-Wlong-long]
#elif (UINTPTR_MAX <= 0xFFFFFFFF)
^
/usr/include/stdint.h:132:23: note: expanded from macro 'UINTPTR_MAX'
#define UINTPTR_MAX UINT64_MAX
^
/usr/include/stdint.h:87:27: note: expanded from macro 'UINT64_MAX'
#define UINT64_MAX 18446744073709551615ULL
^
In file included from /Users/kennethcochran/programming/libsource/cJSON/tests/print_number.c:24:
In file included from /Users/kennethcochran/programming/libsource/cJSON/tests/unity/src/unity.h:16:
/Users/kennethcochran/programming/libsource/cJSON/tests/unity/src/unity_internals.h:77:12: error:
'long long' is an extension when C99 mode is not enabled [-Werror,-Wlong-long]
#elif (UINTPTR_MAX <= 0xFFFFFFFFFFFFFFFF)
^
/usr/include/stdint.h:132:23: note: expanded from macro 'UINTPTR_MAX'
#define UINTPTR_MAX UINT64_MAX
^
/usr/include/stdint.h:87:27: note: expanded from macro 'UINT64_MAX'
#define UINT64_MAX 18446744073709551615ULL
^
3 errors generated.
make[2]: *** [tests/CMakeFiles/print_number.dir/print_number.c.o] Error 1
make[1]: *** [tests/CMakeFiles/print_number.dir/all] Error 2
make: *** [all] Error 2
I just switched the compiler flag from c89 to c99 in CMakeLists.txt to work around this for now.
Hm, seems like the testing framework I'm using doesn't completely follow ANSI C after all.
For now you can fix this by not building the testing framework with -DENABLE_CJSON_TEST=Off
Thanks!
On Sun, Jun 24, 2018, 2:15 PM Max Bruckner [email protected] wrote:
Hm, seems like the testing framework I'm using doesn't completely follow ANSI C after all.
For now you can fix this by not building the testing framework with -DENABLE_CJSON_TEST=Off
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/DaveGamble/cJSON/issues/275#issuecomment-399780319, or mute the thread https://github.com/notifications/unsubscribe-auth/AD9PCoauQYrffAIkQhfbRkKkuuEXdTN2ks5t_-VhgaJpZM4U09hA .
I pushed a possible fix to the long-long-fix
branch, can you check if that fixes it?
That does not fix the error. It's still trying to #include <stdint.h>
I did the following:
rm -rf build
git pull
git checkout long-long-fix
git clean -f
git reset --hard
mkdir build
cd build
cmake ..
make
Same error as far as I can tell.
Then I'll have to take a closer look at it next week. What version of Xcode did you use to install Clang?
Version 9.2 (9C40b)
and here's the compiler version
$ cc --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
I can't seem to reproduce this with (Apple LLVM version 9.0.0 (clang-900.0.39.2)
. (commandline tools installed separately without downgrading Xcode).
I will try downgrading Xcode next.
Still cannot reproduce it, do you have some additional compiler flags set?
env | grep CFLAGS
Do you have a 32 bit system?
env | grep CFLAGS
does not return anything.
It is 64 bit.
If it helps, here's the full output when compiling with cmake .. && make
: https://gist.github.com/kennycoc/5d3ce6d4b90fadb16a6a9f3da8840d9b
Seems like it is still includint stdint.h
and the long long
comes in the form of a literal.
Hm.
Just hit this issue on macOS 11.1 - trivial fix is to change std=c89 to std=c99 i CMakeLists.txt as suggested above