A
asterisc
Hi there,
Before getting a binary, there is the following sequence of steps:
- preprocessing
- compilation
- assembly
- linking
Is there any rule at which level should the inline work?
I mean, where should we see the effect of the inline keyword ?
I have the following fairly simple piece of code:
//test.cpp
#include <iostream>
inline void increment( int& i )
{
++i;
}
#define INCREMENT(i) (++i)
int main()
{
int i = 0;
increment( i );
std::cout << i << endl;
INCREMENT(i);
std::cout << i << endl;
}
The #define is replaced in the preprocessing step.
As far as I could check, the effect of the inline is only at the
assembling step, where we won't have a call to the increment()
function. (if we apply an optimization)
The preprocessed source looks exactly the same as the .cpp file, only
the #define was expanded.
Is that the normal behavior?
Another question, how is inline working with a virtual member
function? (if we call that function thru a base pointer which point to
a derived object)
Thanks in advance
Before getting a binary, there is the following sequence of steps:
- preprocessing
- compilation
- assembly
- linking
Is there any rule at which level should the inline work?
I mean, where should we see the effect of the inline keyword ?
I have the following fairly simple piece of code:
//test.cpp
#include <iostream>
inline void increment( int& i )
{
++i;
}
#define INCREMENT(i) (++i)
int main()
{
int i = 0;
increment( i );
std::cout << i << endl;
INCREMENT(i);
std::cout << i << endl;
}
The #define is replaced in the preprocessing step.
As far as I could check, the effect of the inline is only at the
assembling step, where we won't have a call to the increment()
function. (if we apply an optimization)
The preprocessed source looks exactly the same as the .cpp file, only
the #define was expanded.
Is that the normal behavior?
Another question, how is inline working with a virtual member
function? (if we call that function thru a base pointer which point to
a derived object)
Thanks in advance