United States |
Previous | Contents | Index |
Compaq C supports several VAX C extensions to ANSI-standard C. These extensions are recognized only when the VAX C compatibility option is used on the compiler command line. The VAX C extensions allow you to use the Compaq C compiler to compile code originally written for the VAX C compiler.
The following sections describe the VAX C extensions available with the VAX C compatibility option. Extensions to the ANSI-standard C language are divided into two categories:
main_program |
char lower(int c_up) main_program { . . . } |
char lower(c_up) main_program int c_up; { . . . } |
1 Parameters to the function main() are only checked in strict ANSI mode. |
E.2 Extensions Incompatible with ANSI C
#include <stdio.h> enum packet_type {TEXT, INTEGER}; /* This structure can contain either a text_packet or an integer value. It can only contain one of these at a time, since they share the same storage. */ struct packet { enum packet_type type; variant_union { variant_struct { int str_size; char *text; } text_packet; variant_struct { int value; } value_packet; } text_or_int; } packet = {TEXT, 24 ,"I love the color purple"}; main() { if (packet.type == TEXT) printf(" %s. \n",packet.text); else printf(" %d \n", packet.value); packet.type = INTEGER; packet.value = 42; printf(" The meaning of life, the universe, and everything is: %d. \n", packet.value); } |
Index | Contents |
|