C
Charles Harrison Caudill
Forgive the ignorance, I don't have k&r w/ me at the moment:
is there a way to do inline in ansi 89? 99?
is there a way to do inline in ansi 89? 99?
Charles Harrison Caudill said:Forgive the ignorance, I don't have k&r w/ me at the moment:
is there a way to do inline in ansi 89? 99?
C99 has `inline'. C89/90 does not.Charles said:Forgive the ignorance, I don't have k&r w/ me at the moment:
is there a way to do inline in ansi 89? 99?
Charles Harrison Caudill said:Forgive the ignorance, I don't have k&r w/ me at the moment:
is there a way to do inline in ansi 89? 99?
In said:C99 has `inline'. C89/90 does not.
The closest you can come to inlining in C89 is through the use of (some
often pretty ugly) macros, which you should *definitely* avoid if possible.
In said:In C89 it is not possible, in a standard way, to turn OFF inlining.
It surely is: use a function pointer initialised in a different
translation unit.
In said:Well, the linker could still inline the code. Also, the code
could be inlined at runtime (in a bytecode implementation),
or even by a CPU. More info:
http://www.cuj.com/documents/s=8906/cujexp0311sutter/sutter.htm
Well, the linker could still inline the code. Also, the code
could be inlined at runtime (in a bytecode implementation),
or even by a CPU. More info:
http://www.cuj.com/documents/s=8906/cujexp0311sutter/sutter.htm
Not if you do it right:
In the translation unit containing the definition of foo:
typedef void func(void);
func *array[5] = {foo, foo, foo, foo, bar};
In the translation unit calling foo:
typedef void func(void);
extern func *array[5];
...
array[rand() % 4]();
Show me the system smart enough to realise that this expression can be
*always* substituted by a call to foo.
In said:In C89 it is not possible, in a standard way, to turn OFF inlining.
It surely is: use a function pointer initialised in a different
translation unit.
Well, the linker could still inline the code. Also, the code
could be inlined at runtime (in a bytecode implementation),
or even by a CPU. More info:
http://www.cuj.com/documents/s=8906/cujexp0311sutter/sutter.htm
Not if you do it right:
In the translation unit containing the definition of foo:
typedef void func(void);
func *array[5] = {foo, foo, foo, foo, bar};
In the translation unit calling foo:
typedef void func(void);
extern func *array[5];
...
array[rand() % 4]();
Show me the system smart enough to realise that this expression can be
*always* substituted by a call to foo.
Quote me the portion of the ANSI C standard that says it's not
allowed to make such a substitution.
As a practical matter, you've turned off inlining in at least 99.99%
of implementations. Probably 100% of existing ones.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.