Jin
Jin

Reputation: 113

What is the '\' operator in the C language?

The example that I am looking at is like this:

#define CONTROL_MEM_SIZE    ((CONTROL_ITEM_SIZE * CONTROL_QUEUE_SIZE) +   \
                            portQUEUE_OVERHEAD_BYTES)

I haven't seen the '\' operator. What is this?

Upvotes: 3

Views: 1861

Answers (3)

pmg
pmg

Reputation: 108938

C11 p5.1.1.2: Translation phase 2

Each instance of a backslash character (\) immediately followed by a new-line character is deleted, splicing physical source lines to form logical source lines. [...]

Upvotes: 0

maerics
maerics

Reputation: 156434

The \ character at the end of a line is a line continuation.

It tells the preprocessor to ignore the newline and consider the following line as part of this one.

Compare to the VBScript _ line continuation character.

Upvotes: 3

Carl Norum
Carl Norum

Reputation: 224964

It's not an operator, really. It's just a line extension - it tells the preprocessor that the #define replacement text continues on the next line of the file.

Check out #3 at this link:

Continued lines are merged into one long line. A continued line is a line which ends with a backslash, \. The backslash is removed and the following line is joined with the current one.

Upvotes: 10

Related Questions