What does "\" mean in the C ++ header?

10

I was looking at the MFC header and I do not know what the "\" character means in this context:

#define BEGIN_MESSAGE_MAP(theClass, baseClass) \
PTM_WARNING_DISABLE \
    
asked by anonymous 28.09.2015 / 23:21

1 answer

10

When you use #define it assumes that the code will have only one line. Unlike normal code, preprocessing directives do not end the line with a ; , the line ends when there is a line break.

What if you need to make a code there that requires multiple lines? You need to indicate that the bottom row is a continuation of that #define and not a new row. In this context the \ character is used to inform the preprocessor.

So in this example the bottom line is part of this same #define and there is certainly one more line below it that is also part of this #define , since the second line also has a continuity indicator. >

Like all the features used in the preprocessor, this needs to be used with care because it is easy to think that it is doing something and having a different result than expected.

    
28.09.2015 / 23:29