mikroC

making it simple...

mikroC - C Compiler for Microchip PIC microcontrollers

Note: There is also a third version of #include directive, rarely used, which assumes that neither < nor " appears as the first non-whitespace character following #include:

#include macro_identifier

It assumes a macro definition exists that will expand the macro identifier into a valid delimited header name with either of the <header_name> or "header_name" formats.

Preprocessor Operators

The # (pound sign) is a preprocessor directive when it occurs as the first non- whitespace character on a line. Also, # and ## perform operator replacement and merging during the preprocessor scanning phase.

Operator #

In C preprocessor, character sequence enclosed by quotes is considered a token and its content is not analyzed. This means that macro names within quotes are not expanded.

If you need an actual argument (the exact sequence of characters within quotes) as result of preprocessing, you can use the # operator in macro body. It can be placed in front of a formal macro argument in definition in order to convert the actual argument to a string after replacement.

For example, let’s have macro LCD_PRINT for printing variable name and value on LCD:

#define LCD_PRINT(val)

Lcd_Out_Cp(#val ": "); \

 

Lcd_Out_Cp(IntToStr(val));

(note the backslash as a line-continuation symbol)

 

 

page

 

MikroElektronika: Development tools - Books - Compilers

131