This question already has answers here:
How will i know whether inline function is actually replaced at the place where it is called or not?
(10 answers)
Closed 8 years ago.
I am trying to diagnose a weird performance problem that I think is related to a failure of GCC to inline some function calls in C++, though I am not sure which function calls. Is there a flag to GCC to list all line numbers where inlining was performed?
The answer to your question is here:
C++: How will i know whether inline function is actually replaced?.
The question was slightly different from yours, but the responses are spot-on - and definitely enlightening. I encourage you to read them.
In answer to your question, however:-Winline will generate a warning if the compiler chooses not to inline:
https://gcc.gnu.org/onlinedocs/gcc-4.6.3/gcc/Warning-Options.html
Related
This question already has answers here:
Order of evaluation in C++ function parameters
(6 answers)
Closed 4 years ago.
As far as we know, the function argument evaluation order is not defined by c++ standard.
For example:
f(g(), h());
So we know it is undefined.
My question is, why cant c++ standard define the order of evaluation from left to right??
Because there is no good reason to do so.
The c++ standard generally only defines what is necessary and leaves the rest up to implementers.
This is why it produces fast code and can be compiled for many platforms.
This question already has answers here:
Changing a macro at runtime in C
(5 answers)
Closed 5 years ago.
Right now I'm merging two codes with the same core, but they differentiate with the #defines, what I need is to make a way around it an choose wicth configuration I need on run time, the code uses if ENABLE(defined) to verify the configurations to load, how can I modify the code to make it work?
Thanks
You can't. Macro are pre-processor. They are gone during compilation.
Variables are the best choice.
By the way, this question is answered here.
Changing a macro at runtime in C
This question already has answers here:
Benefits of inline functions in C++?
(14 answers)
What is the purpose of an "inline" function definition? [duplicate]
(6 answers)
Closed 6 years ago.
I know how inline functions work, but I've read they are only a suggestion to the compiler, and the compiler may decide to make an inline function non-inline and make a non-inline function inline. Since compilers know what they are doing far better than I do, why should I even bother making a function inline if the compiler is going to do what it thinks is best? How much do compilers listen to my "suggestions"?
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Does there exist a static_warning?
Is there a way to implement non fatal messages at compile time just like static_assert do when its condition fail? Having a message that shows up always when the compiler encounters it is not enough, I want it to show up when, for example, a template is instantiated.
Would BOOST_STATIC_WARNING work for you?
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Undefined Behavior and Sequence Points
Is there any one know that whether this is valid or not in C++
int a = 0;
a = a++;
Someone told me that it will generate unknown behavior under C++ standard, did anyone know why, and where in the C++ standard states that? Thanks!
I've posted it before, and I will post it again:
http://www.slideshare.net/olvemaudal/deep-c
highly recommended for anybody with such questions in mind
The techincal reason why is that you should not modify the same variable twice (either directly or due to side effects) between sequence points.
Here is an SO question with good answers that clarifies this further and describes sequence points in general.
I don't know about the standard per se (its probably referenced from the C standard anyway), but here you can read about it:
http://www.research.att.com/~bs/bs_faq2.html#evaluation-order