Skip to Content.
Sympa Menu

freetds - [freetds] alloca() usage, building master pre-0.95 on Windows

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Ramiro Morales <cramm0 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: [freetds] alloca() usage, building master pre-0.95 on Windows
  • Date: Sat, 2 May 2015 18:14:33 -0300

Hi all,

When trying to build the tools binaries with Visual studio 2008 (VC9)
(actually a free subset called the Microsoft Visual C++ Compiler
Package for Python 2.7) after tds.lib, db-lib and ctlib.lib have been
built successfully (Thanks Frediano and Larry!), this happens:

C:\>nmake -nologo -fNmakefile CONFIGURATION=release PLATFORM=win32 apps
cl -nologo -W3 -EHsc -TC -Gm -errorReport:prompt -D
"_MBCS" -D "_LIB" -D "WIN32" -D MSDBLIB -D "_CRT_SECURE_NO_WARNINGS"
-D _CRT_NONSTDC_NO_DEPRECATE -D _WIN32_WINNT=0x0400 -I "include" -I
"win32" -I "include\x64" -MD -O2 -D "_NDEBUG" -Zi
-Fesrc\apps\win32\release\bsqldb.exe
-Fd"src\apps\win32\release\vc80.pdb" src\apps\bsqldb.c -link
-LIBPATH:src\dblib\win32\release db-lib.lib Ws2_32.lib shell32.lib
bsqldb.c
...
db-lib.lib(token.obj) : error LNK2019: unresolved external symbol
_alloca referenced in function _tds_process_nbcrow
src\apps\win32\release\bsqldb.exe : fatal error LNK1120: 1 unresolved
externals
NMAKE : fatal error U1077:
'"C:\Users\Me\AppData\Local\Programs\Common\Microsoft\Visual C++ for
Python\9.0\VC\Bin\cl.EXE"' : return code '0x2'
Stop.

This is because there is one usage of alloca() in src/tds/token.c.

With this toolchain, alloca() is available, not as a C runtime library
function but is inserted inline by the compiler instead. Problem is:
To get it to work and not generate the link-time error above, the
malloc.h header file needs to be included (I suspect it contains the
needed pre-processor+compiler magic so the inlining happens).

My question is: What would be the best path to fix this?:

1. Modify token.c to use another function instead of alloca, e.g.
malloc() which is widely used elsewhere in the code base?
2. Patch token.c so it conditionally #include <malloc.h> if Visual C
is detected?
3. Another option?

The only other Microsoft toolchain I have available is the Microsoft
WIndows SDK v7.1 which is also free and compatible with Visual studio
2010 I think and I see the same error there. Would be interested in
experiences of users of newer commercial Visual Studio editions but I
suspect the situation will be similar.

Regards,

--
Ramiro Morales
@ramiromorales




Archive powered by MHonArc 2.6.24.

Top of Page