lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] _get_output_format() signature MinGW 4


From: Vadim Zeitlin
Subject: [lmi] _get_output_format() signature MinGW 4
Date: Wed, 22 Jun 2011 01:53:10 +0200

 Hello again,

 Reviewing my changes I realized that I forgot another small problem I had
when building LMI with MinGW 4: the return value of _get_output_format() is
'unsigned" and not just "int". Hence the line

extern "C" int _get_output_format(void) {return 1;}

in main_common.cpp results in an error about incompatible redeclaration of
this function and I had to change it to

extern "C" unsigned int _get_output_format(void) {return 1;}

to fix this. I don't really understand why was "int" used for MinGW 3 as
looking at its stdio.h I see that _get_output_format() is declared as
returning "unsigned" there too. I guess this declaration somehow wasn't
parsed at all when using it (as it's inside an #if check) and, of course,
at linking time the return type doesn't matter.

 So maybe we could just change this "int" to "unsigned" without any further
complications. But if for some reason it really must be "int" for the old
versions, we could do something ugly like this:

extern "C"
#if __GNUC__ >= 4
unsigned
#endif
int _get_output_format(void) {return 1;}


 But this is ugly and looking at the message referenced in the comment
above this function I see that apparently using this function is some sort
of a hack in the first place and that, quoting
http://article.gmane.org/gmane.comp.gnu.mingw.user/28747

        adding PRINTF_EXPONENT_DIGITS=2 to your environment remains 
        the preferred way to achieve this

 So maybe we could do this instead? Or, potentially even simpler, why not
call _set_output_format(1) instead of replacing _get_output_format()? I am
not sure to understand all the ramifications of VC CRT version influence on
MinGW though so maybe this isn't as simple as that... but then again, maybe
it is?

 Thanks,
VZ

reply via email to

[Prev in Thread] Current Thread [Next in Thread]