Ben Allison wrote:> As mentioned before, this removes some of the 'inline' from the bitreader > and bitwriter functions that were used in another translation unit. I'm > surprised that this code works on other platform. It must be a bug in > GCC, or maybe deliberately non-standard behavior. See 6.7.4 of the C99 > spec for details.I've read section 6.7.4 from here: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf My reading of that section suggests that the usage in FLAC is valid and correct. As for the addition of safe_malloc_mul_2op_ to file src/share/utf8/utf8.c, that simply should not be necessary. I suggest this is an error in the Visual Studio project files. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
> Ben Allison wrote: > >> As mentioned before, this removes some of the 'inline' from the >> bitreader >> and bitwriter functions that were used in another translation unit. >> I'm >> surprised that this code works on other platform. It must be a bug in >> GCC, or maybe deliberately non-standard behavior. See 6.7.4 of the C99 >> spec for details. > > I've read section 6.7.4 from here: > > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf > > My reading of that section suggests that the usage in FLAC is valid and > correct.Take, for example, the function FLAC__bitreader_is_consumed_byte_aligned. It is prototyped in bitreader.h It is used in stream_decoder.c, so it must be defined and made available to the linker ("external definition"). However, the only definition in bitreader.c has been declared inline.
On Mon, Mar 11, 2013 at 08:30:18AM -0400, Ben Allison wrote:> Take, for example, the function FLAC__bitreader_is_consumed_byte_aligned. > It is prototyped in bitreader.h It is used in stream_decoder.c, so it > must be defined and made available to the linker ("external definition"). > However, the only definition in bitreader.c has been declared inline. > > From 6.7.4.6 > An inline definition does not provide an external definition for the > function, and does not forbid an external definition in another > translation unit. An inline definition provides an alternative to an > external definition, which a translator may use to implement any call to > the function in the same translation unit.My understanding is that it's not an "inline definition" as there is a non-inline declaration in bitreader.h. If there are no better solutions to fix the problem, I'd suggest to #define inline to nothing for MSVC. -- Miroslav Lichvar
On Mon, Mar 11, 2013 at 08:51:43AM -0400, Ben Allison wrote:> >> From 6.7.4.6 > >> An inline definition does not provide an external definition for the > >> function, and does not forbid an external definition in another > >> translation unit. An inline definition provides an alternative to an > >> external definition, which a translator may use to implement any call to > >> the function in the same translation unit. > > > > My understanding is that it's not an "inline definition" as there is > > a non-inline declaration in bitreader.h. > > I don't see how that can be the case. The spec explicitly states that > inline definitions do not provide an external definition. >But it's not an inline definition according to 6.7.4.6 (the sentence before the part you have quoted): If all of the file scope declarations for a function in a translation unit include the inline function specifier without extern, then the definition in that translation unit is an inline definition. -- Miroslav Lichvar