Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preprocessing tokens and white spaces

Tags:

c

If I have the following macro:

#define A 10 * 2

does that macro replacing list have 5 preprocessing tokens or only 3?

According to the C11 standard it seems as white space is a separation token

The categories of preprocessing tokens are: header names, identifiers, preprocessing numbers, character constants, string literals, punctuators, and single non-white-space characters that do not lexically match the other preprocessing token categories.

like image 653
xdevel2000 Avatar asked Mar 17 '23 23:03

xdevel2000


1 Answers

It has three tokens: two preprocessing numbers with an * in between. Whitespace is not a token.

The line you quoted includes the wording: single non-white-space characters; that is specifically not whitespace.

The standard goes on to say that tokens "can be separated by white space" and that "White space may appear within a preprocessing token only as part of a header name or between the quotation characters in a character constant or string literal", all of which pretty clearly state that whitespace is not a token.

like image 178
rici Avatar answered Mar 27 '23 22:03

rici