Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

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’ objects are 4 bytes wide:
          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. They incorrectly reject the above program with the diagnostic “Variable-length arrays cannot have static storage.” This bug comes from HP compilers' mishandling of sizeof (int), not from the ? 1 : -1, and Autoconf works around this problem by casting sizeof (int) to long int before comparing it.


 
 
  Published under the terms of the GNU General Public License Design by Interspire