I want to use the library "VCL Style Utils" in Embarcadero C++Builder 10.2 Tokyo.
So I created a new project and added:
Vcl.Styles.Utils.Graphics.pas
Vcl.Styles.Utils.Menus.pas
Vcl.Styles.Utils.SysControls.pas
Vcl.Styles.Utils.SysStyleHook.pas
The build is successful and generates .hpp
files for these .pas
files.
Then I create another project and include the .hpp
files generated.
But when building I get this error:
[bcc32 Error] Vcl.Styles.Utils.Menus.hpp(164): E2040 Declaration terminated incorrectly.
Here are lines 163 and 164 of Vcl.Styles.Utils.Menus.hpp :
static const System::Word MN_SETHMENU = System::Word(0x1e0);
static const System::Word MN_GETHMENU = System::Word(0x1e1);
Why are these declarations incorrect ?
There are likely pre-existing
#define
statements forMN_SETHMENU
andMN_GETHMENU
in another C/C++ header file that is in scope, eg:If so, that would interfere with the declarations generated in
Vcl.Styles.Utils.Menus.hpp
, making the compiler see them as:Which is clearly wrong, and hence the errors.
In
Vcl.Styles.Utils.Menus.pas
(and in.pas
files in general), the declarations forMN_SETHMENU
andMN_GETHMENU
(and anything else that is already pre-defined in C/C++ headers) need to be marked with the{$EXTERNALSYM ...}
directive so they are not re-declared in the generated.hpp
file, eg:If necessary, use the
{$HPPEMIT '...'}
directive to add suitable#include
statements to the generated.hpp
file so it can pull in other C/C++ header files as needed, eg: