Tencent / rapidjson

A fast JSON parser/generator for C++ with both SAX/DOM style API
http://rapidjson.org/
Other
14k stars 3.5k forks source link

Build fails on macOS due to Include/rapidjson/msinttypes/stdint.h #2249

Closed joey-chance closed 5 months ago

joey-chance commented 5 months ago

I am working on a project that was initially built on Windows but I am on Mac. I am trying to build it using CLion and CMake however I got an error saying:

Include/rapidjson/msinttypes/stdint.h:38:2: error: "Use this header only with Microsoft Visual C++ compilers!"
#error "Use this header only with Microsoft Visual C++ compilers!"

I checked Include/rapidjson/msinttypes/stdint.h and found:

#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]

Is there a solution to this since rapidjson is supposed to be cross-platform compatible?

TheOtherDave commented 5 months ago

I found this in rapidjson.h

#if defined(_MSC_VER) && (_MSC_VER < 1800)  // Visual Studio 2013
#include "msinttypes/stdint.h"
#include "msinttypes/inttypes.h"
#else
// Other compilers should have this.
#include <stdint.h>
#include <inttypes.h>
#endif

Looks to me like you probably shouldn't be including anything from the msinttypes directory directly, but I'm not sure.

joey-chance commented 5 months ago

Agreed, I excluded it from the build and it worked. Thanks!