From -1166474090811759940
X-Google-Thread: f78e5,6978327f896d5d5b
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news2.google.com!proxad.net!proxad.net!news-hub.cableinet.net!blueyonder!news-out.ntli.net!newsrout1.ntli.net!news-in.ntli.net!ntli.net!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: jdennett@acm.org (James Dennett)
Newsgroups: comp.std.c++
Subject: Re: What is the use of the null directive # ?
Date: Mon, 28 Jun 2004 05:36:13 +0000 (UTC)
Organization: Cox Communications
Lines: 81
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <UHJDc.1912$151.142@fed1read02>
References: <607f883e.0406251028.5412fc80@posting.google.com> <PDUseaDh1V3AFwzm@robinton.demon.co.uk> <barmar-AEE035.22095526062004@comcast.dca.giganews.com> <Bt9PFkEEEq3AFwhq@robinton.demon.co.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: mail2news.demon.co.uk 1088400973 21892 10.0.0.1 (28 Jun 2004 05:36:13 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Mon, 28 Jun 2004 05:36:13 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.12)
	id 1BeooO-0005gx-00
	for mail2news@news.news.demon.net; Mon, 28 Jun 2004 05:36:12 +0000
X-Received: from mulga.cs.mu.OZ.AU (localhost [127.0.0.1]) by mulga.cs.mu.OZ.AU with ESMTP
	id i5S5aAb9026737; Mon, 28 Jun 2004 15:36:10 +1000 (EST)
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id i5S5aAYO026728;
	Mon, 28 Jun 2004 15:36:10 +1000 (EST)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Path: comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Delivered-To: std-c++@ucar.edu
X-Authentication-Warning: fed1read02.mgt.cox.net: news set sender to newsmaster@cox.net using -f
X-User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.6) Gecko/20040113
X-Accept-Language: en-us, en
X-Newsgroups: comp.std.c++
X-NNTP-Posting-Date: Sun, 27 Jun 2004 20:33:56 EDT
X-Spam-Checker-Version: SpamAssassin 2.60-mulga_r1 (1.212-2003-09-23-exp) on 
	mulga.cs.mu.OZ.AU
X-Spam-Status: No, hits=-4.8 required=5.2 tests=AWL,BAYES_00,
	MAILTO_TO_SPAM_ADDR autolearn=no version=2.60-mulga_r1
Xref: g2news1.google.com comp.std.c++:1051

Francis Glassborow wrote:

> In article <barmar-AEE035.22095526062004@comcast.dca.giganews.com>, 
> Barry Margolin <barmar@alum.mit.edu> writes
> 
>> In article <PDUseaDh1V3AFwzm@robinton.demon.co.uk>,
>> francis@robinton.demon.co.uk (Francis Glassborow) wrote:
>>
>>> In article <607f883e.0406251028.5412fc80@posting.google.com>, Prateek R
>>> Karandikar <kprateek88@yahoo.com> writes
>>> >What is the use of the null-directive # ?
>>> >
>>> ><quote>
>>> >   16.7 Null directive           [cpp.null]
>>> >1  A preprocessing directive of the form
>>> >       # new-line
>>> >   has no effect.
>>> ></quote>
>>>
>>> It allows implementors to add directives as extensions without having
>>> impact on the portability of code using them.
>>
>>
>> All it says is that the line:
>>
>> #
>>
>> is ignored.  How does that allow an implementor to add something like:
>>
>> #foobar
> 
> 
> No it does not say that the implementor is _required_ to ignore such a 
> directive. 

In fact, it says *nothing* about how an implementation can
or must interpret something such as
#foobar
but rather says only that
#
has no effect in a conforming compiler

> What it does say is that such a directive is not cause to 
> abort compilation, nor does its existence require a diagnostic.

You're thinking, perhaps, of the requirement that #praga foo, where
foo is not a recognized pragma name, should be a no-op.

> It generalises the #pragma directive so that I can write:
> 
> #packed
> 
> happy in the knowledge that any compiler that does not understand that 
> directive will simply ignore it.

That generalization is explicit in the standard, and independent
of how
#
is interpreted -- an isolated # portably does nothing, but
#pragma packed
might do anything at all, if the compiler so chooses to "recognize"
the "packed" pragma.  For example, on one compiler #pragma packed
might control alignment within objects, while another could quite
legally implement it to mean that the generated *code* should be as
small as possible.

To avoid the risk of such name clashes, some considerate
implementors put their own pragmas effectively into another
namespace, and allow them to be used as
#pragma __VENDOR_X__ packed
which are unlikely to be "recognized" and interpreted
differently by another system.

-- James

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



