M
Martin Wells
C89 doesn't have inline but I wanted to use inline in my C89-compliant
program. Someone suggested to me that I use macros to determine
whether inline was supported, and if necessary, simply define it like:
#define inline /* nothing */
, and then define the functions within header files with static
inline:
static inline void Func(void) {}
Something was nagging at me though, some reason why the static-ness of
the function would make it somehow different from plain old inline.
When total it finally occured to me:
static inline void Func(void)
{
static int count = 0;
}
*With* static, each translation unit has its own "count". WithOUT
static, there's only one "count" for the entire program.
Anyway just thought I'd share. . .
Martin
program. Someone suggested to me that I use macros to determine
whether inline was supported, and if necessary, simply define it like:
#define inline /* nothing */
, and then define the functions within header files with static
inline:
static inline void Func(void) {}
Something was nagging at me though, some reason why the static-ness of
the function would make it somehow different from plain old inline.
When total it finally occured to me:
static inline void Func(void)
{
static int count = 0;
}
*With* static, each translation unit has its own "count". WithOUT
static, there's only one "count" for the entire program.
Anyway just thought I'd share. . .
Martin