Freigeben über


How to: Distinguish Between Precompile and Compile Error Messages

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

When you are developing code that contains macros, you must understand whether an error message is generated during the precompile or the compile phase. The two key words to look for are:

  • Lexical – This indicates a precompile error.

  • Syntax – This indicates a compile error.

Prerequisites

For this topic, you must understand the information in How to: Use #define and #if to Test a Macro.

Code Examples

The following table shows X++ examples that illustrate lexical and syntax errors related to macro use.

Code

Description

#define.MyMacro1(info("Hello");)

A Lexical error caused by the first closing parenthesis, which marks the end of the directive. Therefore the precompiler is confused by the last two characters ;).

#define.MyMacro2(++++iTest;)

#MyMacro2

A Syntax error caused by using the non-existent ++++ operator. The X++ compiler encounters this operator after #MyMacro2 is replaced by the macro value.

The macro definition is correct even though its value is not accepted X++ syntax.

See also

Macros in X++

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.