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] |
Now I found different statements in discussions and online artcilesTrue. Compared to other C++ compilers, GCC gives the programmer more control over whether things are inlined, including more often simply obeying the inline keyword. But in the language standard the inline keyword is just a hint. Whether GCC obeys that hint depends on a variety of switches and other factors.
saying
1. The inline keyword is just a hint. The compiler decides if it uses
it or not.
2. C'tors and d'tors are always automatically inlined.
3. GCC does not use the inline keyword but has its own ideas aboutThe inline keyword is usually one of many factors in deciding whether a function is inlined.
inlining function calls.
4. GCC does inlining not below -O3 or the explizit activation usingI'm not sure. I think the decision rules are more complex and depend on more switches and there would be exceptions to a statement as simple as the above.
-finline-functions
4. Everything defined in a header file is inlined.Nonsense.
False.inline_test.h:6: warning: inline function âint Foo::GetX() constâ used but never defined
Seems perfectly correct to me, because the definition of GetX is not
known at a point its code should be inlined. It was alreay compiled
into object code when compiling inline_test.cpp.
On the other hand, that would mean, that the compiler _always_ has to
obey to the inline keyword if the definition is given in a cpp file.
Using the Intel 10 compiler at a decent level of optimization, it is a constant source of frustration that there is no way to tell it to not inline things defined in header files. The project I work on has some very large templates that must be in header files and shouldn't be inlined. The Intel 10 compiler always uses its own judgment and its own judgment is usually wrong.And that also means to me, that there is no way to _not_ inline code if it is given in the header file,
It can compile the function to objectcode andThe intermediate form between the compiler and the linker allows for the compiler to generate a non inline copy of a function in each object module in which it is needed and then have the linker detect the duplication, keep only one copy, and connect all calls to that one copy.
use that more than once within one object if there are multiple calls.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |