274 |
|
|
275 |
Compilers and Preprocessors |
Compilers and Preprocessors |
276 |
|
|
277 |
|
* Specific Compiler Characteristics:: Some portability issues |
278 |
* Generic Compiler Characteristics:: Language independent tests |
* Generic Compiler Characteristics:: Language independent tests |
279 |
* C Compiler:: Checking its characteristics |
* C Compiler:: Checking its characteristics |
280 |
* C++ Compiler:: Likewise |
* C++ Compiler:: Likewise |
4634 |
compiling. |
compiling. |
4635 |
|
|
4636 |
@menu |
@menu |
4637 |
|
* Specific Compiler Characteristics:: Some portability issues |
4638 |
* Generic Compiler Characteristics:: Language independent tests |
* Generic Compiler Characteristics:: Language independent tests |
4639 |
* C Compiler:: Checking its characteristics |
* C Compiler:: Checking its characteristics |
4640 |
* C++ Compiler:: Likewise |
* C++ Compiler:: Likewise |
4641 |
* Fortran 77 Compiler:: Likewise |
* Fortran 77 Compiler:: Likewise |
4642 |
@end menu |
@end menu |
4643 |
|
|
4644 |
|
@node Specific Compiler Characteristics |
4645 |
|
@subsection Specific Compiler Characteristics |
4646 |
|
|
4647 |
|
Some compilers exhibit different behaviors. |
4648 |
|
|
4649 |
|
@table @asis |
4650 |
|
@item Static/Dynamic Expressions |
4651 |
|
Autoconf relies on a trick to extract one bit of information from the C |
4652 |
|
compiler: using negative array sizes. For instance the following |
4653 |
|
excerpt of a C source demonstrates how to test whether @samp{int}s are 4 |
4654 |
|
bytes long: |
4655 |
|
|
4656 |
|
@example |
4657 |
|
int |
4658 |
|
main (void) |
4659 |
|
@{ |
4660 |
|
static int test_array [(unsigned long) (sizeof (int)) == 4 ? 1 : -1]; |
4661 |
|
test_array [0] = 0 |
4662 |
|
return 0; |
4663 |
|
@} |
4664 |
|
@end example |
4665 |
|
|
4666 |
|
@noindent |
4667 |
|
To our knowledge, there is a single compiler that does not support this |
4668 |
|
trick: the HP C compilers (the real one, not only the ``bundled'') on |
4669 |
|
HP-UX 11.00: |
4670 |
|
|
4671 |
|
@example |
4672 |
|
$ @kbd{cc -c -Ae +O2 +Onolimit conftest.c} |
4673 |
|
cc: "conftest.c": error 1879: Variable-length arrays cannot \ |
4674 |
|
have static storage. |
4675 |
|
@end example |
4676 |
|
@end table |
4677 |
|
|
4678 |
@node Generic Compiler Characteristics |
@node Generic Compiler Characteristics |
4679 |
@subsection Generic Compiler Characteristics |
@subsection Generic Compiler Characteristics |
4680 |
|
|