Stop om message directive

Top  Previous  Next

User interface > Translation options > Processor options > Stop om message directive

 

StopOnMessage

 

This option is part of the processor options. If the is enabled the pre-processor will stop as soon as such a message will remain in the code, that means,  that the conditions for this code section are true. It will not stop, if the conditions for the code section with the message aren't true.

 

Delphi message directive are used in most cases to indicate, that something is wrong in the code. A typical example of such a directive is:

 

{$MESSAGE ERROR 'Unknown platform'}

 

If correct definitions are set, such messages normally will be part of code sections for which the conditions are false.The option to stop on message directives therefore will not apply. But e.g. the recommended PUREPASCAL definition is problematic. If it is defined.the definition of ASSEMBLER should be avoided. But for example in the following code snippet there is no PUREPASCAL alternative. Therefore the function definition would be reduced to a function declaration.

 

 

function Get8087CW: Word;

{$IF defined(CPUX86) and defined(ASSEMBLER)}

asm

        PUSH    0

        FNSTCW  [ESP].Word

        POP     EAX

end;

{$ELSEIF defined(CPUX64) and defined(ASSEMBLER)}

asm

        PUSH    0

        FNSTCW  [RSP].Word

        POP     RAX

end;

{$ELSE }

{$MESSAGE ERROR 'Unknown platform'}

{$ENDIF}

 

->

 

function Get8087CW: Word; 

{$MESSAGE ERROR 'Unknown platform'} 

 

 

If another function follows, Delphi2Cpp will regard it as a sub function of the remained function declaration and the parser will not stop. The parsing error occurs at a much later position then and the real cause of the error is difficult to find. If the option to stop on messages is enabled, the true error position is set. Delphi2Cpp stops and the message is shown on the log-panel:

 

 

UnknownPlatform

 

On the other side, there are messages which you might want to ignore. In the following case Delphi2Cpp isn't able to calculate the correct result of the condition:

 

  {$IF SizeOf(Extended) <> SizeOf(TExtended80Rec)}

    {$MESSAGE ERROR 'TExtended80Rec has incorrect size'}

  {$ENDIF }

 

 

 

The consequences of the option to stop on message directives depend on the level of the current file. If this option is enabled and if this message appears in the actual file, the whole translation for this file will be stopped. If the message appears in a dependant file, only the processing of that file will be stopped and the message will be shown without stopping the translation of the actual file.

 

If the definitions cannot be changed such that the message directives disappear, it's the best to prepare your Delphi source code accordingly.

 

 



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content