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

Asked

Viewed 143 times

11

I was looking at the MFC header and I don’t know what the character " " means in this context:

#define BEGIN_MESSAGE_MAP(theClass, baseClass) \
PTM_WARNING_DISABLE \

1 answer

11


When you use #define it assumes that the code will have only one line there, unlike normal code, so the 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 several lines? You should indicate that the bottom line is a continuation of that #define and not a new line. In this context the character \ is used to inform this to the pre-processor.

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

Like all the features used in the preprocessor this needs to be used carefully because it is easy to find that you are doing a thing and have resulted different than expected.

  • Vlw, I was having trouble finding that answer

  • 1

    I know the AP is very specific about the context, but I think it’s best to edit the answer to improve it in the sense that this character is not only for use in #define. It can be very useful also to define long strings, for example. :)

  • 1

    @Luizvieira In this case I will leave only your comment even, I will change just to clarify the context. Thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.