A tip for using Firemonkey and VCL on different Embarcadero C++ projects

I use Embarcadero C++ for a lot of work. Sometimes Firemonkey is the right framework to use and sometimes VCL is. I have a lot of C++ files that contain classes that are equally useful for both frameworks.

 Instead of having

 #include <fmx.h>

 or

 #include <vcl.h>

at the tops of the files, for all *.cpp files that can be applied equally in either framework, I use the following line:

#include “EmbarcaderoComponentLibrary.h”

The file EmbarcaderoComponentLibrary.h resides in every project I create and is edited once at the start of the project design. It contains the following lines (along with a load of comment statement which I don’t reproduce):

//*****************************************************************

//Set these for each project requirements

#define ROGER_USE_VCL 1

#define ROGER_USE_FMX 0

//******************************************************************/

#ifndef EMBARCADEROCOMPONENTLIBRARY_H

#define EMBARCADEROCOMPONENTLIBRARY_H

#if ROGER_USE_VCL

#include <vcl.h>

 #endif

 #if ROGER_USE_FMX

 #include <fmx.h>

 #endif

 #endif

 //*****************************************************************

 

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s