NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Microsoft Extensions to C and C++

The following are Visual C++ extensions to the ANSI C and ANSI C++ standards:

Keywords

Microsoft extends the C++ language with several additional keywords. For a complete list, see C++ Keywords in the C++ Language Reference. Keywords with two leading underscores are Microsoft extensions.

Out of Class Definition of static const Integral (or enum) Members

Under the standard (/Za), you need to make an out-of-class definition for data members. For example,

class CMyClass {
   static const int max = 5;
   int m_array[max];
   }
...
const int CMyClass::max;   // out of class definition

Under /Ze, the out-of-class definition is optional for static, const integral, and const enum data members. Only integrals and enums that are static and const can have initializers inside a class; the initializing expression must be a const expression.

To avoid errors when an out-of-class definition is provided (when the out-of-class definition is provided in a header file and the header file is included in multiple source files), you should use selectany. For example,

__declspec(selectany) const int CMyClass::max = 5;

Casts

The compiler supports the following two non-ANSI casts:

Variable-Length Argument Lists

The compiler supports use of a function declarator that specifies a variable number of arguments, followed by a function definition that provides a type instead:

void myfunc( int x, ... );
void myfunc( int x, char * c )
{ }

Single-Line Comments

The C compiler supports single-line comments, which are introduced with two forward slash (//) characters:

// This is a single-line comment.

Scope

The C compiler supports the following scope-related features:

Data Declarations and Definitions

The C compiler supports the following data declaration and definition features:

Intrinsic Floating-Point Functions

The compiler supports inline generation of the x86 Specific —> atan, atan2, cos, exp, log, log10, sin, sqrt, and tan functions END x86 Specific when the Generate Intrinsic Functions (/Oi) option is specified. For C, ANSI conformance is lost when these intrinsics are used, because they do not set the errno variable.

Passing a Non-Const Pointer Parameter to a Function that Expects a Reference to a Const Pointer Parameter

This is an extension to C++. The following code will compile with /Ze:

typedef   int   T;

const T  acT = 9;      // A constant of type 'T'
const T* pcT = &acT;   // A pointer to a constant of type 'T'

void func2 ( const T*& rpcT )   // A reference to a pointer to a constant of type 'T'
{
   rpcT = pcT;
}

T*   pT;               // A pointer to a 'T'

void func ()
{
   func2 ( pT );      // Should be an error, but isn't detected
   *pT   = 7;         // Invalidly overwrites the constant 'acT'
}

new Operator Does Not Throw Exception

When the new operator fails to allocate the requested memory, no exception will be thrown; a null pointer is returned instead.

Scope of Variable in for Loop Stays in Effect After Loop

The following code will compile under /Za. However, to keep compatibility with older code bases, it will not compile under /Ze:

int main () {
   for (int i = 0; i<1; ++i);
   for (int i = 0; i<1; ++i);
   return 0;
}

Use /Zc:forScope if you want to enable Microsoft extensions (/Ze) and standard behavior for for loops.

ISO646.H Not Enabled

Under /Ze, you have to include iso646.h if you want to use text forms of the following operators:

See Also

/Za | /Ze (Disable Language Extensions) | Compiler Options | Setting Compiler Options