Microsoft C/C++ supports the ANSI C standard. In addition, it offers a number of features beyond those specified in the ANSI C standard. These features are enabled when the /Ze (default) option is in effect and disabled when the /Za option is in effect. They include the following:
The __based, __cdecl, __far, __fastcall, __fortran, __huge, __near, __pascal, __stdcall, __syscall, and __interrupt keywords.
Use of casts to produce l-values:
int *p;
(( long * ) p )++;
The preceding example could be rewritten to conform with the ANSI C standard as follows:
p = ( int * )(( long * )p + 1 );
Redefinitions of extern items as static:
extern int foo();
static int foo()
{}
Use of trailing commas (,) rather than an ellipsis (...) in function declarations to indicate variable-length argument lists:
int printf( char *, );
Use of benign typedef redefinitions within the same scope:
typedef int INT;
typedef int INT;
Use of mixed character and string constants in an initializer:
char arr[5] = {'a', 'b', "cde"};
Use of bit fields with base types other than unsigned int or signed int.
Use of single-line comments, which are introduced with two slash characters:
// This is a single-line comment.
Casting of a function pointer to a data pointer:
int ( * pfunc ) ();
int *pdata;
pdata = ( int * ) pfunc;
To perform the same cast while maintaining ANSI compatibility, you must cast the function pointer to an int before casting it to a data pointer:
pdata = ( int * ) (int) pfunc;
Function declarators have file scope:
void func1()
{
extern int func2( double );
}
void main( void )
{
func2( 4 ); // /Ze passes 4 as type double
} // /Za passes 4 as type int
Use of declarators without either a storage class or a type:
x;
void main( void )
{
x = 1;
}
Use of zero-sized arrays as last field in structures and union:
struct zero
{
char *c;
int zarray[];
};
Use of block scope variables initialized with nonconstant expressions:
int foo( int );
int bar( int );
void main( void )
{
int array[2] = { foo( 2 ), bar( 4 ) };
}
int foo( int x )
{
return x;
}
int bar( int x )
{
return x;
}
Previous function declarator specifies a variable number of arguments, but the function definition provides a type instead:
void myfunc( int x, ... );
void myfunc( int x, char * c )
{ }
Use the /Za option if you plan to port your program to other environments. The /Za option tells the compiler to treat extended keywords as simple identifiers and to disable the other extensions listed above.
When you specify /Za, the compiler automatically defines the __STDC__ identifier. In the include files provided with the C run-time libraries, this identifier is used with #ifndef to control use of the __cdecl keyword on library function prototypes. For an example of this conditional compilation, see the file STDIO.H.