[Top][All Lists]

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

Re: [lmi] Upgrading to gcc-4.9.2

From: Vadim Zeitlin
Subject: Re: [lmi] Upgrading to gcc-4.9.2
Date: Sun, 20 Dec 2015 20:25:34 +0100

On Sun, 20 Dec 2015 18:06:27 +0000 Greg Chicares <address@hidden> wrote:

GC> Replacing _get_output_format() works the same way as replacing snprintf().
GC> We're doing it locally in lmi, but that's really no different than doing
GC> it in libmingwex. We want _get_output_format() to specify standard
GC> behavior, which happens to mean returning 1 always; what could be more
GC> natural, obvious, and perfect than implementing it as "{return 1;}" ?
GC> And this seems to be a common, widely discussed practice that nobody has
GC> found fault with over the years.
GC> You must be seeing some problem to which I'm oblivious. What can it be?

 I finally decided to stop talking about the problem and just test how does
it actually work with the following simple test:
---------------------------------- >8 --------------------------------------
#include <stdio.h>

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

int main()
#ifdef USE_SET
    printf("%u: %e\n", _get_output_format(), 1.2345678);
---------------------------------- >8 --------------------------------------

 Here are my results:

Compiler        USE_GET USE_SET Diagnostics     Output
MinGW 3.4.5                                     0: 1.234568e+000
                X                               1: 1.234568e+000
                        X       ERROR[1]
... with -ansi                          0: 1.234568e+000
                X                               1: 1.234568e+00
                        X       ERROR[1]
MinGW-w64 4.9.1                         0: 1.234568e+000
                X               WARNING 1: 1.234568e+000
                        X                       1: 1.234568e+00
                X       X       ERROR[2]

[1] Error due to _set_output_format() being not declared, if I provide
    a declaration manually I get a link error due to it being not defined.

[2] Error due to "multiple definition of `_get_output_format'" coming from
    libmsvcrt.a and the example code, clearly the fact of using
    _set_output_format() pulls in this library resulting in this.

I didn't fill the results for TDM-GCC 5.1.0 x64 which I already tested
because they're identical to MinGW-w64 4.9.1. More importantly, I didn't
add the results for 4.9.1 nor 5.1.0 with -ansi because they are also
identical! I.e. when I was worrying about this hack not working with the
future versions of MinGW, I was really worrying too much: it already
doesn't work with the current versions. I could determine when exactly did
it stop working if you're really interested, but at this point I think it's
pretty clear that it has to be changed.

 Unfortunately, it will have to continue to be used for 3.4.5 for as long
as you want to support it because it doesn't have _set_output_format().
Hopefully this won't be needed for very long, but right now we absolutely
do need to use _set_output_format() just to get the correct results with
gcc 4.9 as, I think, the tests above made it clear.

 Please let me know if you still disagree,

reply via email to

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