I
Ian
Peace, language lawyers!
I'm developing a (static) library for a "memory-challenged"
platform (ie, mobile).
I want to (force the compiler to) inline some functions -- that
are not meant to be exported to the library's clients.
Example:
file1.c:
// Exported.
public_foo( void ); // Calls my_bar() and common_bar().
// Private.
static INLINE my_bar( void ); // Only called by functions in
this translation unit.
INLINE common_bar( void ); // May be called from other
translation units, too.
file2.c:
// Exported.
public_another_foo( void ); // Calls common_bar().
Currently, to inline and prevent exporting, I #include a file with
the static INLINE function.
This is not _standard_ C, but most compilers do provide some
"inline" keyword as a language extension.
Questions:
1. Is there a readable, manageable, semi-portable way to inline
functions in a library?
2. Your experience with compilers (especially GCC, VC, ARM's,
TI's): will they allow inlining, especially of non-static
functions, when building a library?
)
I'm developing a (static) library for a "memory-challenged"
platform (ie, mobile).
I want to (force the compiler to) inline some functions -- that
are not meant to be exported to the library's clients.
Example:
file1.c:
// Exported.
public_foo( void ); // Calls my_bar() and common_bar().
// Private.
static INLINE my_bar( void ); // Only called by functions in
this translation unit.
INLINE common_bar( void ); // May be called from other
translation units, too.
file2.c:
// Exported.
public_another_foo( void ); // Calls common_bar().
Currently, to inline and prevent exporting, I #include a file with
the static INLINE function.
This is not _standard_ C, but most compilers do provide some
"inline" keyword as a language extension.
Questions:
1. Is there a readable, manageable, semi-portable way to inline
functions in a library?
2. Your experience with compilers (especially GCC, VC, ARM's,
TI's): will they allow inlining, especially of non-static
functions, when building a library?