dimanche 24 mai 2015

C++: Conditional changes in a header file

I am working on a feature, the code changes of which need to be guarded by checking registry keys. In .cpp files, I can simply check if the registry key is on or not and subsequently add the code changes. Here's an example:

bool isRegistryKeyOn = SomeMethodToCheckRegistryKey();
if(isRegistryKeyOn)
{
    // New code goes here..
}
else
{
    // Older one's here..
}

Now, I am facing a problem during changes in the header file. Suppose the header contains the following declarations:

class SomeClass
{
    long var;
    ...
};

typedef int A;

And as part of the feature, I need this:

class SomeClass
{
    long long var;
    ...
};

typedef int A;
typedef long long B;

How can I get around this requirement? All solutions, including the out-of-the-box ones are welcome!

Aucun commentaire:

Enregistrer un commentaire