first.obj : error LNK2019: unresolved external symbol snprintf referenced in function hexdump [\curl\b\tests\libtest\lib526.vcxproj]
C:\WORK\GITHUB\dev\curl\b\tests\libtest\Release\lib526.exe : fatal error LNK1120: 1 unresolved externals [\curl\b\tests\libtest\lib526.vcxproj]
How to reproduce:
cmake .. -G"Visual Studio 11 Win64"
cmake --build . --config Release
mprintf.h header added to test.h to prevent future issues in libtest
fixed libtest linker error on msvc
IMHO, adding -Dsnprintf=_snprintf to the CFLAGS would be cleaner. I don't know how since CMake is gibberish to me.
@gvanem according to documentation _snprintf has different semantic from snprintf (for example http://stackoverflow.com/questions/7706936/is-snprintf-always-null-terminating/13067917#13067917). If this not important I can do the trick with little update in CMakeLists.txt
Waiting for more comments.
I don't think snprintf() vs. _snprintf() matters for libtests/*.c files.
Your patch removes the use of the internal snprintf(), why does that solve the problem? Why shouldn't the windows built versions also use that?
@bagder it not removes. I include it in single place test.h and remove duplication.
Ah, thanks for clearing that out. I was clearly not reading the whole patch. With me being corrected. I can't see any problems with this patch!
Oh, unless of course you build with CURLDEBUG defined. It shows we have some further cleaning up work to do... (use of sprintf() that we frown upon)
Ok. Will check it soon. Perhaps I'll need also update cmake build to honor CURLDEBUG option, because I'm not currently aware of that.
Ah right. With the configure build you use --enable-debug to switch it on, and it enables extra debugging info, checks and outputs in various way.
Well, some clarification --enable-curldebug - enables TrackMemory feature, while --enable-debug - enables both (Debug && TrackMemory). Am I correct?
Another question - should it be wirtten to curlbuild.h or as autoconfig do - just set definition to Makefiles?
I've submitted another pull request #145 to handle CURLDEBUG define for build in cmake.
@bagder what should we do, when CURLDEBUG enabled?
Code from mprintf.h will definetely break the build
/* When built with CURLDEBUG we define away the sprintf functions since we
don't want internal code to be using them */
# define sprintf sprintf_was_used
# define vsprintf vsprintf_was_used
# define sprintf curl_msprintf
# define vsprintf curl_mvsprintf
I think that since curl/mprintf.h is a public header, it should not feature that #ifdef in the first place. I think I'll help out here and move that debug-#define sequence into a private libcurl header instead.
libtest: fixed linker errors on msvc
Thanks, I cleaned up the include thing first, then merged your patch!