Last update Wed Mar 30 15:48:20 2016

C Language Implementation

The C language standard (C99) is:
"Programming Languages - C", ANSI/ISO/IEC 9899-1999


File naming conventions

Digital Mars C++ uses the following naming conventions for file extensions. To avoid confusion, do not use these extensions with other file types.

File Types
Extension File types
.c C source files
.h C header files
.cpp C++ source files
.h C++ header files
.obj Object files

For more information on how the compiler processes files, see Compiling Code.

Note: For compatibility with other compilers, .cxx, .hpp, and .hxx are also valid extensions for C++ source and header files for the compiler. These extensions have fallen out of favor and should not be used in the future.

Header Files

The two ways to write #include statements are used to tell the preprocessor where to look for the source file.

With an include statement in the form,

#include <filename>

the preprocessor searches for filename along the list of paths specified by the -I option. If not found, the search continues along the list of paths specified by the INCLUDE environment variable. This type of include statement is used for system include files. Alternatively, with an include statement of the form,

#include "filename"

the preprocessor searches for filename in the default directory. If the file is not found, the compiler searches for filename as if it had been enclosed in angle brackets (<>). This type of include statement is for user include files.

With either type of include statement, if the file extension is .hpp, and if the preprocessor can't find the file, it repeats the search using the file extension .h.

The compiler treats character strings between double quotes ("") or <> pairs as a file name. This allows you to use almost any character, including spaces, the single ('), the backslash (\), or the sequences slash-apostrophe (/*) or double slash (//) in a file name. The compiler does not allow the new-line character to appear between the file name delimiters.

Notice that the backslash character is not used as an escape character in include path strings. Instead, backslash has the same meaning as it does on the command line, denoting a subdirectory of the current directory. For example,

#include <sys\stat.h>

tells the preprocessor to look for stat.h in the sys subdirectory, which is the focus of current search.

The compiler ignores case in file names and accepts pathnames of any length up to the maximum allowed by the operating system.

To create an include path list, use either the command line option, -I, or the environment variable, INCLUDE. In both cases, the list consists of one or more pathnames separated by semicolons. The compiler first checks paths that are specified on the command line, and then the paths in INCLUDE. Pathnames are typically absolute paths, but you can use relative pathnames as well. If you specify a relative pathname, it is considered relative to the same directory as the enclosing file.

There is no compiler limit on the number of nested #include directives or the number #include paths. The practical limit is the amount of memory available to the compiler or to the operating system.

Predefined names

If the -A compiler option is specified, the predefined name __STDC__ is defined with the value 1.

Unimplemented Features

While Digital Mars C strives to be fully compatible with C99, some features remain unimplemented, for example:

C Extensions

Auto Prototyping

Generate prototypes for functions based on how they are used, described -p.

Home | Runtime Library | IDDE Reference | STL | Search | Download | Forums