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:30:18AM -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. > > If there are no better solutions to fix the problem, I'd suggest to > #define inline to nothing for MSVC.Looking at the spec again, and using the information in Example 7, I found that if we put the following AFTER the inline definition, it becomes available to other translation units. extern unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br); This appears to be different behavior than other uses of the keyword 'extern' (just like the multiple uses of the keyword 'static'). 6.7.4.7 of the C99 spec suggests that a statement such as the above turns an inline definition into an external definition. Add 'extern' to the .h file is unsafe, as any file that included bitreader.h and chose to define an alternate inline definition (as allowed by the spec) would also end up defining an external definition and would result in duplicate symbols. I will redo the patch with these 'extern' function definitions defined inside the corresponding .c files. Hope that helps. -Ben Allison
>> On Mon, Mar 11, 2013 at 08:30:18AM -0400, Ben Allison wrote: > I will redo the patch with these 'extern' function definitions defined > inside the corresponding .c files.As promised, here is the patch to declare the inline functions as external definitions. -Ben Allison -------------- next part -------------- A non-text attachment was scrubbed... Name: FLAC-1-3-0-inline-extern.patch Type: application/octet-stream Size: 1718 bytes Desc: not available Url : http://lists.xiph.org/pipermail/flac-dev/attachments/20130311/6ef4e855/attachment.obj