RS> But inline is only a request. The compiler does not have to
RS> place the code inline.
True enough. But just why is inline "only a request". There are
a few reasons. First, it may not even be theoretically possible
to inline the code. For example, a virtual function that cannot
be resolved until run-time clearly cannot be inlined at compile
time. Additionally, it may just be too large or complex of code
to inline, so the platform is allowed to punt the inline request
at discretion.
But just because it is legal to ignore the inline doesn't mean that's
how your compiler will be treating the situation. For example,
class X {
private:
int j;
SetJ(int a) {j=a;}
inline int GetJ();
}
int X::GetJ() {
return j;
}
I don't believe you would find a current compiler that would refuse
to inline the member functions.
RS> Would the same apply to a macro?
A macro just does text substitution.
RS> In
RS> other words... even though the preprocessor expands the code
RS> inline the compiler could treat it as if it were a function
RS> call?
I suppose it's possible for a compiler to coalesce common
executable code into subroutines as some sort of optimization
for space. FWIW, I haven't heard of such a thing.
---
þ Blue Wave/QWK v2.12 þ
---------------
* Origin: St. Louis Users Group (1:100/4)
|