www.delorie.com/gnu/docs/autoconf/autoconf_62.html   search  
 
Buy the book!


Autoconf

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.10.1 Specific Compiler Characteristics

Some compilers exhibit different behaviors.

Static/Dynamic Expressions
Autoconf relies on a trick to extract one bit of information from the C compiler: using negative array sizes. For instance the following excerpt of a C source demonstrates how to test whether `int's are 4 bytes long:

 
int
main (void)
{
  static int test_array [sizeof (int) == 4 ? 1 : -1];
  test_array [0] = 0
  return 0;
}

To our knowledge, there is a single compiler that does not support this trick: the HP C compilers (the real one, not only the "bundled") on HP-UX 11.00:

 
$ cc -c -Ae +O2 +Onolimit conftest.c
cc: "conftest.c": error 1879: Variable-length arrays cannot \
    have static storage.

Autoconf works around this problem by casting sizeof (int) to long before comparing it.


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003