Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 ユーザーズマニュアル

製品コード
SW006021-1
ページ / 518
C Language Features
 2012 Microchip Technology Inc.
DS52053B-page 211
The type and conversion of numeric values in the preprocessor domain is the same as 
in the C domain. Preprocessor values do not have a type, but acquire one as soon as 
they are converted by the preprocessor. Expressions may overflow their allocated type 
in the same way that C expressions may overflow.
Overflow may be avoided by using a constant suffix. For example, an L after the num-
ber indicates it should be interpreted as a long once converted.
So for example
#define MAX 1000*1000
and
#define MAX 1000*1000L
will define the values 0x4240 and 0xF4240, respectively.
TABLE 5-11:
PREPROCESSOR DIRECTIVES
Directive
 Meaning
 Example
#
Preprocessor null directive, do nothing #
#assert
Generate error if condition false
#assert SIZE > 10
#asm
Signifies the beginning of inline assem-
bly
#asm
  MOVLW FFh 
#endasm
#define
Define preprocessor macro
#define SIZE 5
 
#define FLAG
 
#define add(a,b) ((a)+(b))
#elif
Short for #else #if
see #ifdef
#else
Conditionally include source lines
see #if
#endasm
Terminate inline assembly
see #asm
#endif
Terminate conditional source inclusion
see #if
#error
Generate an error message
#error Size too big
#if
Include source lines if constant 
expression true
#if SIZE < 10
 
  c = process(10)
 
#else
  skip();
#endif
#ifdef
Include source lines if preprocessor 
symbol defined
#ifdef FLAG
 
  do_loop();
#elif SIZE == 5
  skip_loop();
#endif
#ifndef
Include source lines if preprocessor 
symbol not defined
#ifndef FLAG
  jump();
#endif
#include
Include text file into source
#include <stdio.h>
 
#include “project.h” 
#line
Specify line number and filename for 
listing
#line 3 final
#nn
(Where nn is a number) short for 
#line
 nn
#20
#pragma
Compiler specific options
Refer to 
#undef
Undefines preprocessor symbol
#undef FLAG
#warning
Generate a warning message
#warning Length not set