473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Ansi standard with #defines and \ character

When creating a #define symbol like this,

#define SYMBOL1_OFFSET 100

#define SYMBOL2_OFFSET(SYMBOL1_OFFSET +\

50)

The 50) is on a new line. Can there be any whitespace after the \ character
according to the standard?
May 10 '06 #1
4 1603

"Brand Bogard" <br**********@motorola.com> wrote in message
news:e3**********@newshost.mot.com...
When creating a #define symbol like this,

#define SYMBOL1_OFFSET 100

#define SYMBOL2_OFFSET(SYMBOL1_OFFSET +\

50)

The 50) is on a new line. Can there be any whitespace after the \
character
according to the standard?


Yes, as long as the first whitespace character
after the \ is a newline (\n).

-Mike
May 10 '06 #2
Mike Wahler wrote:
"Brand Bogard" <br**********@motorola.com> wrote in message
news:e3**********@newshost.mot.com...
When creating a #define symbol like this,

#define SYMBOL1_OFFSET 100
#define SYMBOL2_OFFSET(SYMBOL1_OFFSET +\
50)

The 50) is on a new line. Can there be any whitespace after the \
character according to the standard?


Yes, as long as the first whitespace character
after the \ is a newline (\n).


Correct. ;-)

Also, the definition of SYMBOL2_OFFSET is an error. I think the OP
intended to have a space before the left paren.

--
Thad
May 10 '06 #3
"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:DZ**************@newsread2.news.pas.earthlink .net...

"Brand Bogard" <br**********@motorola.com> wrote in message
news:e3**********@newshost.mot.com...
When creating a #define symbol like this,

#define SYMBOL1_OFFSET 100

#define SYMBOL2_OFFSET(SYMBOL1_OFFSET +\

50)

The 50) is on a new line. Can there be any whitespace after the \
character
according to the standard?


Yes, as long as the first whitespace character
after the \ is a newline (\n).

-Mike

And where is that little nugget piece of information documented? I'm not
questioning your answer, I just thought that standard was able to accomodate
more up to date parsers and lexers. Seems like a simple thing to allow.
May 10 '06 #4
"Brand Bogard" <br**********@motorola.com> writes:
"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:DZ**************@newsread2.news.pas.earthlink .net...
"Brand Bogard" <br**********@motorola.com> wrote in message
news:e3**********@newshost.mot.com...
> When creating a #define symbol like this,
>
> #define SYMBOL1_OFFSET 100
>
> #define SYMBOL2_OFFSET(SYMBOL1_OFFSET +\
>
> 50)
>
> The 50) is on a new line. Can there be any whitespace after the \
> character
> according to the standard?


Yes, as long as the first whitespace character
after the \ is a newline (\n).

And where is that little nugget piece of information documented? I'm not
questioning your answer, I just thought that standard was able to accomodate
more up to date parsers and lexers. Seems like a simple thing to allow.


It's documented in the standard.

Translation phase 2 is documented in C99 5.1.1.2p2:

Each instance of a backslash character (\) immediately followed by
a new-line character is deleted, splicing physical source lines to
form logical source lines. Only the last backslash on any
physical source line shall be eligible for being part of such a
splice. A source file that is not empty shall end in a new-line
character, which shall not be immediately preceded by a backslash
character before any such splicing takes place.

I agree that allowing arbitrary whitespace between a '\' and a
new-line character would be an improvement. As it is, a stray space
after a '\' can make a program illegal while being entirely invisible.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

100
by: Roose | last post by:
Just to make a tangential point here, in case anyone new to C doesn't understand what all these flame wars are about. Shorthand title: "My boss would fire me if I wrote 100% ANSI C code" We...
34
by: Sunner Sun | last post by:
Hi! I have looked through the FAQ but found nothing about it. :-) It seems that this kind of macro is platform dependent, doesn't it? Thank you. Sunner Sun
143
by: suri | last post by:
Hello I downloaded glibc and tried looking for the code that implements the sine function i couldnt find the file. i went to the math directory and found math.h.. i guess that needs to be...
17
by: hugo27 | last post by:
hugo27 July 13, 2004 > >The teachy books and documentation I've read do not >mention the Escape key, but everytime I hit it during >runtime my programs go bananas. > >This relates to a larger...
5
by: S.Tobias | last post by:
Since I haven't found any recent reference to it in csc or clc, I would like to bring Readers' attention to the apparent availability of C90 Standard in electronic form from www.ansi.org. I...
47
by: Thierry Chappuis | last post by:
Hi, I'm interested in techniques used to program in an object-oriented way using the C ANSI language. I'm studying the GObject library and Laurent Deniau's OOPC framework published on his web...
8
by: Simon Klein | last post by:
Hi, I've got a problem. I wrote a Program with a Signalhandler Routine. If i use the compile flags "-ansi -pedantic -Wall", "(void) signal(SIGCHLD,Handler)" catches the first signal but ignores...
0
NeoPa
by: NeoPa | last post by:
ANSI-89 v ANSI-92 Before we get into all the various types of pattern matching that can be used, there are two ANSI standards used for the main types of wildcard matching (matching zero or more...
13
by: ramif | last post by:
Is there a way to print extended ASCII in C?? I tried to code something, but it only displays strange symbols. here is my code: main() { char chr = 177; //stores the extended ASCII...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.