This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ 'extern inline' magic possible?


On 1 March 2011 00:25, Ian Lance Taylor  wrote:
> "Kevin P. Fleming" <kpfleming@digium.com> writes:
>
>> I would like to come up with some construction like the 'extern
>> inline' that GCC supports for C mode, so that a.h could contain the
>> declaration *and* definition of 'bar', allowing code that includes a.h
>> to have 'bar' be inlined if the compiler chooses to do so (and leave
>> an external reference to 'bar' if necessary so that the version built
>> from a.cpp will be used). So far my attempts have only resulted in
>> various re-definition or re-declaration errors.
>
> There is no equivalent to GNU C's "extern inline" in C++. ?By the way,
> "extern inline" is now actually known as __attribute__ ((gnu_inline)),
> as C99 defines "extern inline" to mean something different.
>
> In C++ you can simply define the function inline in a.h, and not define
> it at all in a.cpp. ?The right thing will happen.

That will work in practice, but it's technically an ODR violation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]