Skip to Content.
Sympa Menu

freetds - Re: [freetds] building 0.83.dev.20101013 with VC9: _vsnprintf error

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: jklowden AT schemamania.org
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] building 0.83.dev.20101013 with VC9: _vsnprintf error
  • Date: Thu, 14 Oct 2010 09:52:26 -0400

On Thu, Oct 14, 2010 at 11:24:59AM +0200, Roman Neuhauser wrote:
> here's what i got building yesterday's snapshot with VC9.
>
> c:\MinGW\msys\1.0\home\roman\wc\freetds-0.83.dev.20101013>nmake -nologo -f
> Nmakefile FROM_TARBALL= PLATFORM=win32 CONFIGURATION=debug
> cl -nologo -W3 -Wp64 -EHsc -TC -Gm -errorReport:prompt -D
> "_MBCS" -D "_LIB" -D "WIN32" -D "_CRT_SECURE_NO_WARNINGS" -D
> _CRT_NONSTDC_NO_DEPRECATE -D "HAVE_CONFIG_H" -D "_FREETDS_LIBRARY_SOURCE"
> -I "include" -I "win32" -I "include\x64" -c -MTd -Od -D "_DEBUG" -ZI -RTC1
> -Fo"src\replacements\win32\debug\\"
> -Fd"src\replacements\win32\debug\vc80.pdb" src\replacements\asprintf.c
> src\replacements\basename.c src\replacements\fakepoll.c
> src\replacements\gettimeofday.c src\replacements\getopt.c
> src\replacements\iconv.c src\replacements\readpassphrase.c
> src\replacements\strlcat.c src\replacements\strlcpy.c
> src\replacements\strtok_r.c src\replacements\vasprintf.c
...
> getopt.c
> c:\program files\microsoft visual studio 9.0\vc\include\stdio.h(358) :
> error C3163: '_vsnprintf': attributes inconsistent with previous declaration
> c:\program files\microsoft visual studio
> 9.0\vc\include\stdio.h(350) : see declaration of '_vsnprintf'

This looks to be a matter of lying to the compiler.

$ grep -i printf win32/config.h
/* Define to 1 if you have the `asprintf' function. */
/* #undef HAVE_ASPRINTF */
/* Define to 1 if you have the `vasprintf' function. */
/* #undef HAVE_VASPRINTF */
/* Define to 1 if you have the `vsnprintf' function. */
/* #undef HAVE_VSNPRINTF */
/* Define to 1 if you have the `_vsnprintf' function. */
#define HAVE__VSNPRINTF 1

so HAVE__VSNPRINTF is true, but HAVE_VSNPRINTF is not. That's a mistake,
because Microsoft provides vsnprintf(3).

Then, include/replacements.h says:

#if !HAVE_VSNPRINTF
#if HAVE__VSNPRINTF
#undef vsnprintf
#define vsnprintf _vsnprintf
#else
int vsnprintf(char *ret, size_t max, const char *fmt, va_list ap);
#endif /* HAVE_VSNPRINTF */
#endif /* !HAVE__VSNPRINTF */

so the preprocessor has been told to define vsnprintf in terms of _vsnprintf.
When the compiler reads stdio.h, it finds two declaraations: the real one
and our override.

I would try modifying win32/config.h to define HAVE_VSNPRINTF:

#define HAVE_VSNPRINTF 1

HTH.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page