Next: , Previous: ANSI C Compliance, Up: Using the library   [Index]


2.5 Inline functions

The inline keyword is not part of the original ANSI C standard (C89) so the library does not export any inline function definitions by default. Inline functions were introduced officially in the newer C99 standard but most C89 compilers have also included inline as an extension for a long time.

To allow the use of inline functions, the library provides optional inline versions of performance-critical routines by conditional compilation in the exported header files. The inline versions of these functions can be included by defining the macro HAVE_INLINE when compiling an application,

$ gcc -Wall -c -DHAVE_INLINE example.c

If you use autoconf this macro can be defined automatically. If you do not define the macro HAVE_INLINE then the slower non-inlined versions of the functions will be used instead.

By default, the actual form of the inline keyword is extern inline, which is a gcc extension that eliminates unnecessary function definitions. If the form extern inline causes problems with other compilers a stricter autoconf test can be used, see Autoconf Macros.

When compiling with gcc in C99 mode (gcc -std=c99) the header files automatically switch to C99-compatible inline function declarations instead of extern inline. With other C99 compilers, define the macro GSL_C99_INLINE to use these declarations.