"_" prefix in Windows stdlib calls (was: [GSOC]Firebird Integration Weekly Update 03)

Lionel Elie Mamane lionel at mamane.lu
Mon Jul 1 02:01:55 PDT 2013


On Mon, Jul 01, 2013 at 12:17:41AM -0500, Norbert Thiebaud wrote:
> On Sun, Jun 30, 2013 at 2:05 PM, Andrzej J. R. Hunt <andrzej at ahunt.org> wrote:

>> Finally I've had to do things like replace snprintf with _snprintf --
>> currently decided using an ifdef -- this seems somewhat unclean but I'm
>> not sure of any better way to do this.

A Windows expert will maybe correct me, but I think this "_" prefix is
just part of the Windows ABI (name mangling or C name decoration) and
thus should not be in the source code. It should be added
~automatically by the compiler. Since you mention mingw, maybe there
is some subtlety there, but my guess is that the right solution is
something like adding "_cdecl" in front of the function declaration
(not at each call). Or maybe passing some command-line option to the
compiler that means --respect-microsoft-calling-conventions

https://en.wikipedia.org/wiki/Name_mangling#C_name_decoration_in_Microsoft_Windows

-- 
Lionel


More information about the LibreOffice mailing list