Pragmas

Although portability is a hallmark of C, the language's creators recognized that every C compiler will need to support some features unique to its host machine. The “#pragma directive” offers a way for each C compiler to offer machine-specific features while retaining overall compatibility with the C language. Since pragmas are machine-specific by definition, they can be—and usually are—different for every C compiler.

Pragmas have the same general syntax as preprocessor directives. The pragma must begin with a number sign (#) and it can't share a line with other directives or statements except a comment, which must appear to the right of the pragma.

QuickC supports six pragmas: check_stack, check_pointer, message, pack, alloc_text, and loop_opt. Each of these pragmas is described in online help.

Some pragmas take arguments, which come after the #pragma keyword. In the following code, the message pragma displays different messages during compilation depending on the outcome of an #if test:

#if XT == 1

#pragma message( “Building XT version” )

#elif AT == 1

#pragma message( “Building AT version” )

#endif