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

Re: [MiNT] gcc-4.5.2-mint-20110128


On keskiviikko 02 helmikuu 2011, Vincent Rivière wrote:
> Vincent Rivière wrote:
> > 3) As a pleasant side effects, GCC's math-68881.h is now used
> > transparently.
> Paweł has discovered a very annoying bug by compiling the tiff library.
> That math-68881.h distributed with GCC is not compatible with the
> standards C99 or GNU99.
> If you include math.h in multiple files (usually, you do) and you compile
> with: -m68020-60 -O2 -std=c99 (or gnu99)
> then you get multiple definitions of _sin, _cos, etc.
> The behavior of inlines have been well defined in x99 standards.
> The rules are quite obscure:
> http://www.greenend.org.uk/rjk/2003/03/inline.html
> Basically, with the default options, inlining may or may not occur, but
> the functions will never been externally visible. In x99 standard, they
> are :-( Also those inlines use "extern inline", I wonder how this could
> be useful.

See GCC manual:

"This combination of inline and extern has almost the effect of a macro.
The way to use it is to put a function definition in a header file with
these keywords, and put another copy of the definition (lacking inline and
extern) in a library file. The definition in the header file will cause most
calls to the function to be inlined. If any uses of the function remain,
they will refer to the single copy in the library."

I.e. "extern inline" is useful (only) in cases where user of some
header/library doesn't know how to use GCC warnings that tell when one is
using functions without correct include files.  And the header/library
writer for some reason wants things work although they're used incorrectly
(without a header).

> I believe math-68881.h has currently a design bug and has never been
> adapted for the x99 standards.
> I will probably report this problem to the GCC team.
> As a workaround, I advice to use -DNO_INLINE_MATH whenever -std=c99 or
> -std=gnu99 is used. This will solve the link problem, but of course no
> inlining will occur and libm will be used.

	- Eero