Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building with VS2015 #42

Open
Jedzia opened this issue Oct 27, 2016 · 1 comment
Open

Building with VS2015 #42

Jedzia opened this issue Oct 27, 2016 · 1 comment

Comments

@Jedzia
Copy link

Jedzia commented Oct 27, 2016

Don't believe it but finally, Visual Studio 14 defines snprintf()!
It restricts redefinition, this is added in stdio.h:

#ifdef snprintf
    #error: Macro definition of snprintf conflicts with Standard Library function declaration”
#endif

so we get
...\ucrt\stdio.h(1927): fatal error C1189: #error: Macro definition of snprintf conflicts with Standard Library function declaration [...\lua-cjson\build\cjson.vcxproj errors.

My solution to this was skipping of add_definitions(-Dstrncasecmp=_strnicmp) for MSVC14. Patch follows:

CMakeLists.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ca26381..ff74d6f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -71,8 +71,10 @@ endif()
 if(MSVC)
     add_definitions(-D_CRT_SECURE_NO_WARNINGS)
     add_definitions(-Dinline=__inline)
-    add_definitions(-Dsnprintf=_snprintf)
-    add_definitions(-Dstrncasecmp=_strnicmp)
+   if(NOT MSVC14)
+       add_definitions(-Dsnprintf=_snprintf)
+   endif(NOT MSVC14)
+   add_definitions(-Dstrncasecmp=_strnicmp)
 endif()

 add_library(cjson MODULE lua_cjson.c strbuf.c ${FPCONV_SOURCES})

Keep on coding, Jedzia;)

@concatime
Copy link

concatime commented May 27, 2017

Hey, thank you! After the change, it compiled but I got this: warning:
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
It you have a simple solution to solve (and not hide) this warning, I will take it ;)

Wrong post, I wanted to comment on this > #44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants