Background: I'm dealing with some legacy systems on msvc9, and there are problems with floating point to int conversions. It emits a __ftol2_sse
instruction which is an undefined reference if not compiling for SSE.
The only way to suppress this is with the /QIfist
option which performs the conversion inline, without calls to any ftol()
. However, those inline conversions have a different rounding algorithm, and thus cause problems when used with the existing code. That, and they emit unsuppressible 'deprecated' warnings to cl.exe stderr.
The workaround I have is:
// Declare a regular _ftol() function that is present.
long __cdecl _ftol(double);
// Define _ftol2_sse() to be the regular one.
long __cdecl _ftol2_sse(double f) { return _ftol(f); }
And that works nicely. However, some builds do have _ftol2_sse
defined, in which case I get multiple definitions, and it's a pain to figure that out in the code.
I was hoping to do something like --wrap __ftol2_sse
from ld
, and just override the behavior on all builds. Is anything like this possible on MSVC?