Original Post
I've been using '#pragma warning' to specifically raise the level of certain warnings in the event that the compiler doesn't inline any of the functions that I want it to. I totally understand the semantics which imply that the 'compiler (usually) knows best' when it comes to optimization etc, but sometimes having the compiler doing 'things behind your back' can leave you in the dark.
So, any time I wish to inline a function, I want to be warned of the compiler's decision. In that way, I can attempt to re-write the function in a way that would make the complier happy, which (hopefully) in turn would make me a better coder. So it's a win-win situation right?
Well... I'm in the middle of revamping my math (header-only) library which, as you can imagine, needs all the optimization it can get. Virtually all functions are implemented via a single line or two, making them ideal for inlining, and all of them are fully templated so that they can be used with any compatible types.
However, I appear to get no warning whatsoever from my MS Visual C++ 2010 Express complier, even when I resort to bloating up a function using all manner of madness (like exception handling) just to see if I can get my complier to at least cough at me.
I understand that complier warnings C4710 (level 4) and C4714 (also level 4) are raised in the event that ‘inline’ or ‘__forceinline’ get overruled by the compiler so, unless there are any other inline specific warnings out there (and yes I have checked and, just to be certain, enabled all warnings in my code to see if any crop up!) can I simply assume that compilers will ALWAYS inline template functions that are specified as inline?
This is not a serious issue of course, but sometimes it IS nice to know what your compiler is up to.
So, any time I wish to inline a function, I want to be warned of the compiler's decision. In that way, I can attempt to re-write the function in a way that would make the complier happy, which (hopefully) in turn would make me a better coder. So it's a win-win situation right?
Well... I'm in the middle of revamping my math (header-only) library which, as you can imagine, needs all the optimization it can get. Virtually all functions are implemented via a single line or two, making them ideal for inlining, and all of them are fully templated so that they can be used with any compatible types.
However, I appear to get no warning whatsoever from my MS Visual C++ 2010 Express complier, even when I resort to bloating up a function using all manner of madness (like exception handling) just to see if I can get my complier to at least cough at me.
I understand that complier warnings C4710 (level 4) and C4714 (also level 4) are raised in the event that ‘inline’ or ‘__forceinline’ get overruled by the compiler so, unless there are any other inline specific warnings out there (and yes I have checked and, just to be certain, enabled all warnings in my code to see if any crop up!) can I simply assume that compilers will ALWAYS inline template functions that are specified as inline?
This is not a serious issue of course, but sometimes it IS nice to know what your compiler is up to.