Delphi Error – X1030 Invalid compiler directive – ‘%s’

Delphi Compiler Error

X1030 Invalid compiler directive – ‘%s’

Reason for the Error & Solution

This error message means there is an error in a compiler directive or in a command line option. Here are some possible error situations:

  • An external declaration was syntactically incorrect.
  • A command line option or an option in a DCC32.CFG file was not recognized by the compiler or was invalid. For example, ‘-$M100’ is invalid because the minimum stack size must be at least 1024.
  • The compiler found a $XXXXX directive, but could not recognize it. It was probably misspelled.
  • The compiler found a $ELSE or $ENDIF directive, but no preceding $IFDEF, $IFNDEF or $IFOPT directive.
  • (*$IFOPT*) was not followed by a switch option and a + or -.
  • The long form of a switch directive was not followed by ON or OFF.
  • A directive taking a numeric parameter was not followed by a valid number.
  • The $DESCRIPTION directive was not followed by a string.
  • The $APPTYPE directive was not followed by CONSOLE or GUI.
  • The $ENUMSIZE directive (short form $Z) was not followed by 1,2 or 4.

(*$Description Copyright Embarcadero 2009*)    (*<-- Error here*)
program Produce;
(*$AppType Console*)                                     (*<-- Error here*)

begin
(*$If O+*)                                               (*<-- Error here*)
  Writeln('Optimizations are ON');
(*$Else*)                                                (*<-- Error here*)
  Writeln('Optimizations are OFF');
(*$Endif*)                                               (*<-- Error here*)
  Writeln('Hello world!');
end.


The example shows three typical error situations, and the last two errors are caused by the compiler not having recognized $If.

(*$Description 'Copyright Embarcadero 2009'*)  (*Need string*)
program Solve;
(*$AppType Console*)                                     (*AppType*)

begin
(*$IfOpt O+*)                                            (*IfOpt*)
  Writeln('Optimizations are ON');
(*$Else*)                                                (*Now fine*)
  Writeln('Optimizations are OFF');
(*$Endif*)                                               (*Now fine*)
  Writeln('Hello world!');
end.

So $Description needs a quoted string, we need to spell $AppType right, and checking options is done with $IfOpt. With these changes, the example compiles fine.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...