Next: , Previous: Specific Compiler Characteristics, Up: Compilers and Preprocessors


5.10.2 Generic Compiler Characteristics

— Macro: AC_CHECK_SIZEOF (type-or-expr, [unused], [includes = ‘AC_INCLUDES_DEFAULT])

Define SIZEOF_type-or-expr (see Standard Symbols) to be the size in bytes of type-or-expr, which may be either a type or an expression returning a value that has a size. If the expression ‘sizeof (type-or-expr)’ is invalid, the result is 0. includes is a series of include directives, defaulting to AC_INCLUDES_DEFAULT (see Default Includes), which are used prior to the expression under test.

This macro now works even when cross-compiling. The unused argument was used when cross-compiling.

For example, the call

          AC_CHECK_SIZEOF([int *])

defines SIZEOF_INT_P to be 8 on DEC Alpha AXP systems.

— Macro: AC_CHECK_ALIGNOF (type, [includes = ‘AC_INCLUDES_DEFAULT])

Define ALIGNOF_type (see Standard Symbols) to be the alignment in bytes of type. ‘type y;’ must be valid as a structure member declaration. If ‘type’ is unknown, the result is 0. If no includes are specified, the default includes are used (see Default Includes).

— Macro: AC_COMPUTE_INT (var, expression, [includes = ‘AC_INCLUDES_DEFAULT], [action-if-fails])

Store into the shell variable var the value of the integer expression. The value should fit in an initializer in a C variable of type signed long. To support cross compilation (in which case, the macro only works on hosts that use twos-complement arithmetic), it should be possible to evaluate the expression at compile-time. If no includes are specified, the default includes are used (see Default Includes).

Execute action-if-fails if the value cannot be determined correctly.

— Macro: AC_LANG_WERROR

Normally Autoconf ignores warnings generated by the compiler, linker, and preprocessor. If this macro is used, warnings count as fatal errors for the current language. This macro is useful when the results of configuration are used where warnings are unacceptable; for instance, if parts of a program are built with the GCC -Werror option. If the whole program is built using -Werror it is often simpler to put -Werror in the compiler flags (CFLAGS, etc.).

— Macro: AC_OPENMP

OpenMP (http://www.openmp.org/) specifies extensions of C, C++, and Fortran that simplify optimization of shared memory parallelism, which is a common problem on multicore CPUs.

If the current language is C, the macro AC_OPENMP sets the variable OPENMP_CFLAGS to the C compiler flags needed for supporting OpenMP. OPENMP_CFLAGS is set to empty if the compiler already supports OpenMP, if it has no way to activate OpenMP support, or if the user rejects OpenMP support by invoking ‘configure’ with the ‘--disable-openmp’ option.

OPENMP_CFLAGS needs to be used when compiling programs, when preprocessing program source, and when linking programs. Therefore you need to add $(OPENMP_CFLAGS) to the CFLAGS of C programs that use OpenMP. If you preprocess OpenMP-specific C code, you also need to add $(OPENMP_CFLAGS) to CPPFLAGS. The presence of OpenMP support is revealed at compile time by the preprocessor macro _OPENMP.

Linking a program with OPENMP_CFLAGS typically adds one more shared library to the program's dependencies, so its use is recommended only on programs that actually require OpenMP.

If the current language is C++, AC_OPENMP sets the variable OPENMP_CXXFLAGS, suitably for the C++ compiler. The same remarks hold as for C.

If the current language is Fortran 77 or Fortran, AC_OPENMP sets the variable OPENMP_FFLAGS or OPENMP_FCFLAGS, respectively. Similar remarks as for C hold, except that CPPFLAGS is not used for Fortran, and no preprocessor macro signals OpenMP support.

For portability, it is best to avoid spaces between ‘#’ and ‘pragma omp’. That is, write ‘#pragma omp’, not ‘# pragma omp’. The Sun WorkShop 6.2 C compiler chokes on the latter.