0

C++ ISO standard says: "A function defined within a class definition is an inline function." *

Do you know about any compilers that IGNORE this rule?

Do you know about any compilers that WILL NOT put that 'inline suggestion' there?

(please do not repeat the theory about inlines, I am aware of that - I need a practical answer)

id.psycho
  • 21
  • 3
  • Duplicate of http://stackoverflow.com/questions/654452/are-there-any-compilers-that-ignore-c-standard-about-default-inline-functions, asked very recently by same person. – David Thornley Mar 17 '09 at 16:21
  • I'm sorry, I wanted to restate my question - I read FAQ now and will edit my previous one. Sorry for making mess. – id.psycho Mar 17 '09 at 16:31

4 Answers4

1

All compilers are allowed to ignore any inline suggestions they decide to. If they decide the function is too complex, for example, it won't be inlined. If you ever take the address of the function, the function may be inlined in some places, but a full function generated somewhere else for the address to point to.

Think of inline and the implicit inline when you define a function in a class definition as suggestions to the compiler.

Eclipse
  • 44,851
  • 20
  • 112
  • 171
1

It is not a rule, it is simply a statement of fact. The spec is simply stating that the function is defined inline. That makes it easier for the compiler to actually inline the generated code as well, but nowhere does the standard require this.

They're different concepts. What the generated code looks like is up to the compiler alone, and the standard doesn't really impose any requirements (except of course that it should behave as specified).

jalf
  • 243,077
  • 51
  • 345
  • 550
0

In gcc you can use

-finline-limit=n
-fno-inline
Mykola Golubyev
  • 57,943
  • 15
  • 89
  • 102
0

See my answer to a very similar question: When is "inline" ineffective? (in C)

Summary: inline is only required to allow multiple definitions. Any function calling changes is purely optional.

Community
  • 1
  • 1
Richard
  • 106,783
  • 21
  • 203
  • 265