Questions about __attribute__ and noinline (GCC)

Can tell somebody what this mean in C++? (is in front of a function) Also how I find something about this issue.

__attribute__ ((noinline)) 

Thank you . Regards

Upvotes: 2

Views: 8881

Answers (2)

user529758
user529758

Reputation:

Pretty much what the name of this attribute implies. As a kind of heavy optimization, the compiler may chose to inline smaller functions in order to avoid the overhead of function calls. If you don't want your function to be inlined for some reason, you can use this nonstandard attribute to prevent the compiler from doing this optimization.

It is in front of a function

To learn how GCC attributes are organized syntactically, see this guide.

Upvotes: 1

Adam Rosenfield
Adam Rosenfield

Reputation: 400434

GCC defines a number of different non-standard function attributes used for indicating special features of functions. These are usually used for optimization or dealing with platform-specific features.

In this case, the noinline attribute means "don't inline this function under any circumstances", when the optimizer might otherwise inline it.

Upvotes: 3

Related Questions