The inline is mostly useless. This is just a suggestion. The compiler can ignore it and refuse the built-in function, as well as freely embed a function declared without the inline .
If you are really interested in doing the job of calling a function, you should check the resulting assembly to make sure that the function really was (or was not) built-in. I am not familiar with VC ++, but it may have a compiler-specific method of forcing or blocking the embedding of a function (however, the standard C ++ inline will not).
So, I suppose the answer to the wider context of your research is: don't worry about explicit embedding . Modern compilers know when to install and when not, and will usually make better decisions than even very experienced programmers. Therefore, the inline often completely ignored. You should not worry about explicitly forcing or prohibiting the embedding of a function if you do not have a special need to do this (as a result of profiling the execution of your program and determining that a bottleneck can be resolved by forcing the installation of the built-in compiler for some reason not done).
Re: assembly:
; 30 : const unsigned int maxUINT = -1; ; 31 : clock_t start = clock(); mov esi, DWORD PTR __imp__clock push edi call esi mov edi, eax ; 32 : ; 33 :
This assembly:
- Reading hours
- Saving Clock
- Reading hours again
Note what is missing: calling your function is a whole bunch of time
The compiler noticed that you are not doing anything with the result of the function and that the function has no side effects, so it is not called at all.
You can probably get it to call a function anyway by compiling with optimization turned off (in debug mode).
source share