|
Compiling Compiling Code C Implementation C++ Implementation Language Extensions Mixing Languages Assembly Language Inline Assembler Optimizing Code Numerics Programming Regular Expressions Acrtused Pragmas Precompiled Headers Predefined Macros Warning Messages Error Messages Runtime Messages Linking Optlink Switches Module Definition Files Operation and Design Error Messages Win32 Programming Win32 Programming DOS and Win16 Programming Memory Models 16 Bit Pointer Types and Type Modifiers Handle Pointers DOS DOS 32 (DOSX) Win16 Win16 DLLs Win16 Prolog/Epilog C/C++ Extensions Contract Programming __debug statement __debug declaration Dynamic Profiling Embedding C in HTML Tools BCC CHMOD CL COFF2OMF COFFIMPLIB DMC DIFF DIFFDIR DUMP DUMPOBJ DUMPEXE EXE2BIN FLPYIMG GREP HC IMPLIB LIB LIBUNRES MAKE MAKEDEP ME OBJ2ASM PATCHOBJ RC RCC SC SHELL SMAKE TOUCH UNMANGLE WHEREIS Porting to DMC++ Switching to DMC++ from Microsoft from Borland Porting Guide |
C and C++ Language Extensions
Extended Type ModifiersThe following type modifier keywords are extensions to the C and C++ standard:__based, __cdecl, __cs, __declspec, __export, __far, __fortran, __handle, __huge, __interrupt, __loadds, __near, __pascal, __ssThese keywords provide support for mixed language programming and for mixed memory models. Although they are not necessary for all applications, their judicious use can significantly enhance program performance. The keywords __cs, __far, __handle, __huge, __interrupt, __loadds, __near, __ss are applicable for 16 bit programs and are described in 16 Bit Pointer Types and Type Modifiers. Note: The keywords __far, __interrupt, __handle, __loadds, and __huge are ignored by default in compilations using the Win32 (the default) memory model. Ignore these keywords in any compilation by specifying the -NF compiler option. For backwards compatibility with legacy code, the keywords _cs, cdecl, _cdecl, far, _far, near, _near, huge, _huge, pascal, and _pascal are also supported. These are incompatible with the language standards, and so should be replaced wherever found with the versions that have two leading underscores. __cdecl, __fortran, and __pascalThese provide support for calling functions in other languages. For more information, see Mixing Languages.__exportThis keyword aids those programming Microsoft Windows. __export causes the function name to be exported to the linker.__export may also be used to designate all members of a class for export by adding the keyword between the class and the tag name. For example: class __export A {...};
__declspecDigital Mars C++ supports the Microsoft specific keyword __declspec and the related attributes dllimport, dllexport, naked, and thread. Use __declspec along with an attribute when declaring functions or variables, as described below.Note: Like other extended keywords, __declspec is disabled with the -A (ANSI compatibility) compiler option. dllimport and dllexport attributesUse dllimport and dllexport to import and export functions and data objects to and from DLLs.The dllimport attribute takes the place of the IMPORTS statement in a module definition file; it indicates that a function resides in a DLL. The dllexport attribute takes the place of the EXPORTS statement in a module definition file (and the __export keyword). Use it in DLLs to indicate which functions and data objects are available to other applications and DLLs. The syntax for declaring a function or data object with the dllimport or dllexport attributes is: __declspec(dllimport) type name(args); __declspec(dllexport) type name(args); naked attributeThe compiler does not generate prolog and epilog code for functions declared with the naked attribute. This enables you to use inline assembly code to write your own prolog/ epilog.The syntax for declaring a function with the naked attribute is: __declspec(naked) type function_name(args); thread attributeUse the thread attribute to declare a variable to be local to a specific thread in a multi-threaded process. The thread attribute is valid only in 32-bit code.The syntax for declaring a variable with the thread attribute is: __declspec(thread) type variable_name = expr; Emit declarationAn __emit__ declaration is used to embed short assembly language fragments into the body of the code. __emit__ takes a variable number of integer arguments, representing the machine language instructions. The compiler then inserts these instructions into the generated code. For example, the declaration__emit__(0xB47F, 0x89CB, 0xCD21);and inserts these instructions into the code: mov AH,7F mov BX,CX int 21It's probably better to use the inline assembler rather than __emit__. $ in IdentifiersThe dollar sign ($) is a valid character in an identifier. This extension is disabled by the -A switch.Binary integer constantsConstants beginning with the characters 0b are taken to be binary constants. Only the digits 0 and 1 are valid within a binary constant. For example, 0b1101 is a binary integer constant.Win32 Structured Exception HandlingThe __try, __except, and __finally extended syntax to handle Win32 structured exception handling (SEH) is supported. Do not use both C++ and SEH in the same function. |