Amumu
Amumu

Reputation: 18552

What does "| \" mean?

In WINUSER.H, it defines WS_OVERLAPPEDWINDOW like this:

#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED     | \
                             WS_CAPTION        | \
                             WS_SYSMENU        | \
                             WS_THICKFRAME     | \
                             WS_MINIMIZEBOX    | \
                             WS_MAXIMIZEBOX)

What I don't understand is, rather than operator |, what does | \ do?

Upvotes: 4

Views: 261

Answers (7)

Mia Clarke
Mia Clarke

Reputation: 8204

The pipe is a bitwise OR, and the backslash signals that the definition continues on the next line.

Upvotes: 6

Erik
Erik

Reputation: 91270

| is bitwise OR

\ at the end of a line is continuation in next line of something you'd otherwise write in a single line - It merges two physical lines to a logical line.

The below line is equivalent.

#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)

Upvotes: 1

ypercubeᵀᴹ
ypercubeᵀᴹ

Reputation: 115550

The \ is used at the end of the line so the definition can extend to more than one line.

Upvotes: 1

Graeme Perrow
Graeme Perrow

Reputation: 57248

Two separate things. The | is the bitwise OR operator, and the \ is telling the preprocessor to add the stuff on the next line to this line. This is the same as

#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | ...

Upvotes: 1

Bernd Elkemann
Bernd Elkemann

Reputation: 23550

The pipe symbol "|" bitwise or's these constants, the backslash just escapes the following line-wrap.

Upvotes: 2

Mat
Mat

Reputation: 206729

\ as the LAST character of a line means "this line is not finished". It disappears from the preprocessed output.

Those lines are equivalent to:

#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | ...

just a bit more readable.

Upvotes: 6

Joe
Joe

Reputation: 42627

The \ is simply a line continuation character; it means the next physical line is part of the same logical line. It's just for readability.

Upvotes: 1

Related Questions