mercredi 8 mai 2019

C++ Stop Preprocessor Macro Expansion

Here is my example code https://godbolt.org/z/f5MUPT

#define delete ThisShouldNotshowUp

#define _helper(first, second) first ## second
#define CAT(X,Y) CAT2(X,Y)
#define CAT2(X,Y) X##Y
#define CAT_2 CAT
#define CAT_3(X,Y,Z) CAT(X,CAT(Y,Z))    


class A {
    A() = CAT_3(de,le,te);
};

The godbolt example is setup to display the preprocessor output. The goal is that at the end of the preprocessor pass i want the output code to be

class A {
    A() = delete;
};

currently "ThisShouldNotshowUp" is displayed there instead. I thought the use of the ## operator would stop the preprocessor from reexpanding but it did not.

I realize removing the "#define delete" would solve the problem but I need this define there.

Aucun commentaire:

Enregistrer un commentaire