Support This Project Get i5/OS Programmer's Toolkit at SourceForge.net. Fast, secure and Free Open Source software downloads

EMI Compiler Directives

All EMI compiler directives start with character '/'. Compiler directives supported by EMI by now are

/include Directive

Directive /include can be used to include other source units from a specific source unit. Format of directive /include is:
/include ["]path-name["];
description

Conditional Compilation Directives

Directive /define, /undef, /ifdef, /ifndef, /endif, /else are designed for conditional compilation. The following table shows the formats of EMI's conditional compilation directives.

Directive Name Format Description

/define /define macro-name define a macro

/undef /undef macro-name undefine a macro

/ifdef /ifdef macro-name test if a macro has been defined

/ifndef /ifndef test if a macro has NOT been defined

/endif /endif end the most recent /ifdef or /ifndef group

/else /else as its literal meanings

Example of Using EMI Conditional Compilation Directives

In the following example, source unit oct1.emi includes another source unit oct-inc.emi. We can see two typical usage of conditional compilation directives here.

/* *
 * @file oct1.emi
 *
 * includes oct-inc.emi
 */

/define __chinese__         ;  /* defines MACRO __chinese__ */
        
entry * ext                     ;

dcl dd buf char(40) auto        ;
dcl dd hex char(2) auto         ;
dcl dd str char(4) auto init('19EF') ;

        cvtch hex, str          ;

        cpyblap oct-err,
          oct-greeting,
          " "                   ;
        triml oct-len, oct-err, ' ' ;
        %sendmsg(oct-err, oct-len)  ;

brk 'RRR'                       ;
        rtx *                   ;

/include oct-inc.emi            ;
/include oct-inc.emi            ; /* includes oct-inc.emi twice */

pend                            ;
/* *
 * @file oct-inc.emi
 */

/ifndef __oct_inc__             ;
/define __oct_inc__             ;

dcl dd oct-err char(32) auto    ;
dcl dd oct-len bin(2) auto      ;

/ifdef __chinese__          ;
dcl con oct-greeting char(16)
        init(x"0E56755655569C55C64DC254CA0F") ;
/else                           ;
dcl con oct-greeting char(32)
        init("Soe said he's a kind man.") ;
/endif                          ;

/endif                          ;

/* eof - oct-inc.emi */

Run program OCT1

> call oct1    
  苏说他是好人

Support This Project
Generated on Mon Aug 1 22:50:22 2011 for i5/OS Programmer's Toolkit: MIC - The Machine Instruction Language Compiler by  doxygen 1.5.9