What does "|" mean?

In WINUSER.H, it defines WS_OVERLAPPEDWINDOW as follows:

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

What I do not understand, not operator | what makes | \ | \ ?

+4
source share
7 answers

\ , since the LAST character of the string means "this string is not finished yet." It disappears from the pre-processed output.

These lines are equivalent:

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

read a little bit.

+6
source

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

+6
source

Pipe symbol "|" bitwise or these constants, the backslash just eludes the next line break.

+2
source

| bitwise OR

\ at the end of the line is a continuation in the next line of what you otherwise write on the same line - it combines two physical lines into a logical line.

The next line is equivalent.

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

\ is just a line continuation character; this means that the next physical line is part of the same logical line. It is just for readability.

+1
source

Two separate things. | is a bitwise OR operator, and \ tells the preprocessor to add material to the next line to this line. This is the same as

 #define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | ... 
+1
source

The \ is used at the end of a line, so the definition can span multiple lines.

+1
source

Source: https://habr.com/ru/post/1342417/


All Articles