itchconfig Documentation
Macros: C Tests

Introduction

The following commands test properties of the C compiler, header files and libraries on a user's computer.

Macro IC_C_COMPILE

Tries to compile the given C source code and stores in id whether this worked (1) or not (0). - behavior: see IC_SUBSTITUTE.

Macro IC_C_LINK

Tries to compile and link the given C source code. id, behavior: see IC_C_COMPILE.

Macro IC_C_RUN

Tries to build and run the given C source code. id, behavior: see IC_C_COMPILE.

If flags & 1, the test will fail if the code can be run but the exit code isn't 0.

If flags & 2, an extra identifier exitcode_id will be created and contain the exit code of the C program. The name of the exitcode_id is constructed by appending "_E" to id; e.g. if id is "FOO", exitcode_id will be named "FOO_E".

If flags & (4 | 8), an extra identifier output_id will be created and contain the output of the C program; if flags & 4, stdout is considered; if flags & 8, stderr is considered. The name of the output_id is constructed by appending "_O" to id; e.g. if id is "FOO", output_id will be named "FOO_O".

Important: exitcode_id and output_id will have well-defined values only if the test didn't fail, i.e. if id contains the value 1!

Macro IC_C_CONST

Tests whether the C compiler handles the modifier "const" correctly. If not, the line "#define const" is added to config.h so that the C pre-processor strips the keyword from the source files before the compiler sees them. If you provide id, the test result is additionally stored as explained in IC_C_COMPILE.

Macro IC_C_INLINE

Tests whether the C compiler handles the modifier "inline" correctly. If not, the line "#define inline iv" is added to config.h, where iv is "__inline__", "__inline" or nothing, depending on the test results ("iv" like "inline variant"); this way, the C pre-processor substitutes or strips the keyword from the source files before the compiler sees them. If you provide id, the test result (1: "inline", "__inline__" or "__inline" works; 0: none of them works) is additionally stored as explained in IC_C_COMPILE.

Macro IC_C_FUNCTIONS

Tests for each of the given C functions whether it is available and stores the test results (1 or 0) in identifiers named "HAVE_tfn". tfn is the transformed function name: all lower-case letters are converted to their upper-case equivalents, and all non-alphanumeric characters are replaced with underscores.

Macro IC_C_FUNCTIONS_OPTLIB

Tests for each of the given functions whether it is available in the libc or the given lib and stores the test results (1: available in libc or lib; 0: not available) in identifiers named "HAVE_tfn". (tfn: see IC_C_FUNCTIONS.) If any of the functions isn't available in libc but only in the lib, the lib will be linked to all given binaries. (If no binaries are given, it will be linked to all binaries that have been formerly created with IC_BINARY_CREATE, and at least one such binary must already have been created.)

Macro IC_C_HEADERS

Tests for each of the given C headers whether it is available and stores the test results (1 or 0) in identifiers named "HAVE_thn". thn is the transformed header name: all lower-case letters are converted to their upper-case equivalents, and all non-alphanumeric characters are replaced with underscores.

Macro IC_C_HEADERS_STDC

Tests whether ANSI-compliant C standard headers are available and stores the result (1 or 0) in id.

Macro IC_C_LIBRARY

Tests whether the library is available (by trying to link it and call the function) and stores the test result (1 or 0) in id. If id isn't given, it will be named "HAVE_tln" by default; tln is the transformed library name: all lower-case letters are converted to their upper-case equivalents, and all non-alphanumeric characters are replaced with underscores.

If you just want to check whether any version of the library is available, you should use a very basic function, e.g. IC_C_LIBRARY(curses, initscr). If you want to check for a special variant of a library which provides special features, you should use a function which is characteristic for that variant and a non-default id.

Macro IC_C_TYPES

Tests whether the each of the types is available. If a type is not available and a replacement is known, a line of the form "typedef tr ti;" is written to config.h; tr is a type replacement, ti is a type identifier from the list types. Replacements for the following types are known: mode_t, off_t, pid_t, size_t; since version 0.0.3 also gid_t, uid_t and ptrdiff_t.

If you need to know a test result (1: type was already available; 0: it wasn't) somewhere in your package, you can get it by setting behavior. This will create a substitution identifier of the form "HAVE_tti"; tti is the transformed ti: all lower-case letters are converted to their upper-case equivalents, and all non-alphanumeric characters are replaced with underscores.

Macro IC_C_FUNCTION_MMAP

Tests whether the C function (and operating system call) mmap() is available and works correctly. If you use this command, don't use the less specific IC_C_FUNCTIONS(mmap)! - If id isn't given, it will be named "HAVE_MMAP".


This documentation file is part of version 0.0.4 of itchconfig, a configuration tool created by Arne Thomaßen. itchconfig is basically released under certain versions of the GNU General Public License and WITHOUT ANY WARRANTY. Copyright (C) 2002 Arne Thomaßen.