How to preprocess MACRO and use value in the constant definition?

89 Views Asked by At

In Delphi, I want to define the constants as follows:

const
  LANG_BUL = MAKELANGID(LANG_BULGARIAN, SUBLANG_DEFAULT);

But will get

[dcc32 Error] Utils.pas(15): E2026 Constant expression expected

How can let the compiler preprocess the macro and generate the constants before the compile starts?

1

There are 1 best solutions below

0
Uli Gerhardt On BEST ANSWER

In Delphi there are no macros. MAKELANGID is a function - see unit Winapi.Windows. As such it can't be used to define a constant. You can manually "expand" MAKELANGID as a workaround:

const
  LANG_BUL =  WORD(SUBLANG_DEFAULT shl 10) or LANG_BULGARIAN;