Alf P. Steinbach wrote:
* Bi*************@gmail.com:
My observation was that a function with `inline' qualifier has file
scope in C++ and it's symbol is not exported.
Presumably by "file scope" you mean internal linkage, and by "not
exported" you mean internal linkage.
Yes you're right on this, after posting I realised `file scope' isn't
what I was trying to say.
Contrary to this, in C an
`inline' function symbol is exported, unless it also has `static' or
`extern' qualifiers.
I think you got this one wrong too.
An external linkage "inline" function must be defined (identically) in
every translation it's used. The "inline" qualifier informs the
compiler and linker that all definitions are the same. Hence the linker
can choose any single one, and you don't get a multiple def error.
By external linkage inline I guess you mean a declaration like:
extern inline void function(void) { }
I have seen the same description (i.e. picking up any definition) as
yours in gcc documentation and it makes sense.
Getting back to my original argument however, using gcc and producing
an object file in C, I have observed that no symbol was exported
(internal linkage) for a function declared "extern inline". This makes
me think, does the compiler avoid multiple def errors by not exporting
the symbol in the object file produced? My expectation would be to have
multiple definitions of same symbol in many object files and the linker
would resolve it by picking only one of them, because they're marked as
external linkage, in the object file level. Incorrect?
If we get back to just "inline" declaration, C compilation did export
the symbol in the object file produced.* However in C++, merely
declaring a function `inline' only, I had no exported symbols from the
file. Do you think this is how it's supposed to be?
Many thanks,
Bahadir
*I am using something like gcc -c file.c to produce the object file.