I want to force a little function not to be compiled as inline function even if it's very simple. I think this is useful for debug purpose. Is there any keyword to do this?
The only situation in which a function cannot be inlined is if there is no definition for the function in the compilation unit. Even that will not prevent link-time inlining by a link-time optimizer.
If you need to make sure that function is inlined and OK to go with proprietary extension in MS VC++, check out the __forceinline declarator. The compiler will either inline the function or, if it falls into the list of documented special cases, you will get a warning - so you will know the inlining status.
There's no guarantee that functions will be inlined. You can't force the compiler to inline a particular function, even with the __forceinline keyword. When compiling with /clr , the compiler won't inline a function if there are security attributes applied to the function. The inline keyword is available only in C++.
In Visual Studio 2010, __declspec(noinline)
tells the compiler to never inline a particular member function, for instance:
class X { __declspec(noinline) int member_func() { return 0; } };
edit: Additionally, when compiling with /clr
, functions with security attributes never get inlined (again, this is specific to VS 2010).
I don't think it will prove at all useful at debugging, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With