Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

comp.lang.c.moderated

8 views
Skip to first unread message

Trevor L. Jackson, III

unread,
Apr 6, 2000, 3:00:00 AM4/6/00
to
My news server is not configured for moderated groups.

Subject:
Re: Question re. C/C++ header files
Date:
05 Apr 2000 02:31:10 GMT
From:
Peter Burka <pe...@quux.net>
Organization:
Foobar Quux & Sons
Newsgroups:
comp.lang.c.moderated
References:
1 , 2

>Barry Schwarz wrote:
>>
>> #ifndef unique_name_usually_mnemonically_similar_to_header_name
>> #define same_unique_name_described_above
>> ... (the real header contents)
>> #endif
>>
>
>You mean
>
>#ifndef unique_name_usually_mnemonically_similar_to_header_name
>#define same_unique_name_described_above
> ... (the real header contents)
>#endif
>
>right?
>
>Preprocessor directives must start in the first column.
>
>/peter
>--
>comp.lang.c.moderated - moderation address: cl...@plethora.net
>

Actually preprocessor directives must be the first non-blank on a line.
Leading whitespace is not an issue.
--
comp.lang.c.moderated - moderation address: cl...@plethora.net

Barry Schwarz

unread,
Apr 16, 2000, 3:00:00 AM4/16/00
to
On Fri, 14 Apr 2000 15:06:37 -0700, Dan Gunter <DKGu...@lbl.gov>
wrote:

>bzzt!
>
>From the documentation on Solaris 5.7 (try "man cpp"):
>
> Directives
> All cpp directives start with a hash symbol (#) as the
> first character on a line. White space (SPACE or TAB char-
> acters) can appear after the initial # for proper indenta-
> tion.
Why would anyone using c care what solaris says about c++?


<<Remove the del for email>>

Kalle Olavi Niemitalo

unread,
Apr 17, 2000, 3:00:00 AM4/17/00
to
Barry Schwarz <schw...@deloz.net> writes:

> On Fri, 14 Apr 2000 15:06:37 -0700, Dan Gunter <DKGu...@lbl.gov>
> wrote:
> >From the documentation on Solaris 5.7 (try "man cpp"):

[...]


> Why would anyone using c care what solaris says about c++?

cpp is the C preprocessor, not the C++ compiler.

Keith Thompson

unread,
Apr 17, 2000, 3:00:00 AM4/17/00
to
Barry Schwarz <schw...@deloz.net> writes:
> On Fri, 14 Apr 2000 15:06:37 -0700, Dan Gunter <DKGu...@lbl.gov>
> wrote:
>
> >bzzt!

> >
> >From the documentation on Solaris 5.7 (try "man cpp"):
> >
> > Directives
> > All cpp directives start with a hash symbol (#) as the
> > first character on a line. White space (SPACE or TAB char-
> > acters) can appear after the initial # for proper indenta-
> > tion.
> Why would anyone using c care what solaris says about c++?

On Solaris, cpp is the C preprocessor.

Of course, the language says nothing about invoking the preprocessor
as a separate program, so I'm not sure how relevant this is (I didn't
see the rest of the thread).

--
Keith Thompson (The_Other_Keith) k...@cts.com <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Welcome to the last year of the 20th century.

Thomas M. Sommers

unread,
Apr 17, 2000, 3:00:00 AM4/17/00
to
Barry Schwarz wrote:
>
> On Fri, 14 Apr 2000 15:06:37 -0700, Dan Gunter <DKGu...@lbl.gov>
> wrote:
>
> >From the documentation on Solaris 5.7 (try "man cpp"):

[snip]

> Why would anyone using c care what solaris says about c++?

cpp is the C preprocessor.

Rasputin

unread,
Apr 17, 2000, 3:00:00 AM4/17/00
to
Barry Schwarz wrote:
>
> On Fri, 14 Apr 2000 15:06:37 -0700, Dan Gunter <DKGu...@lbl.gov>
> wrote:
>
> >bzzt!

> >
> >From the documentation on Solaris 5.7 (try "man cpp"):
> >

> Why would anyone using c care what solaris says about c++?

Um, cpp is the C preprocessor, not the c++ compiler...

Rasputin.
Jack of All Trades - Master of Nuns.

Barry Schwarz

unread,
Apr 19, 2000, 3:00:00 AM4/19/00
to
On 17 Apr 2000 02:46:29 GMT, Kalle Olavi Niemitalo <to...@ees2.oulu.fi>
wrote:

>Barry Schwarz <schw...@deloz.net> writes:
>
>> On Fri, 14 Apr 2000 15:06:37 -0700, Dan Gunter <DKGu...@lbl.gov>
>> wrote:
>> >From the documentation on Solaris 5.7 (try "man cpp"):

>[...]


>> Why would anyone using c care what solaris says about c++?
>

>cpp is the C preprocessor, not the C++ compiler.
The original question was whether a #define or other preprocessor
directive had to appear at the left of the line. Solaris says yes.

K&R2, section A12 states: "Lines beginning with #, perhaps preceded
by white space, communicate with this preprocessor." Seems like
Solaris is a little overly restrictive.


<<Remove the del for email>>

Chris Torek

unread,
Apr 20, 2000, 3:00:00 AM4/20/00
to
If I got all the attributions right:

>>Barry Schwarz <schw...@deloz.net> writes:
>>> Why would anyone using c care what solaris says about c++?

>On 17 Apr 2000 02:46:29 GMT, Kalle Olavi Niemitalo <to...@ees2.oulu.fi>
>wrote:


>>cpp is the C preprocessor, not the C++ compiler.

In article <clcm-2000...@plethora.net>


Barry Schwarz <schw...@deloz.net> writes:
>The original question was whether a #define or other preprocessor
>directive had to appear at the left of the line. Solaris says yes.
>
>K&R2, section A12 states: "Lines beginning with #, perhaps preceded
>by white space, communicate with this preprocessor." Seems like
>Solaris is a little overly restrictive.

The C standard does not even require that a separate preprocessor
*exist*, of course. If you buy the conformant compiler for Solaris
(last I heard, it was an extra-cost item), it comes with a conformant
preprocessor phase that it uses internally.

The "cpp" command happens to invoke an "ancient-compatible" program
that does C style preprocessing. Since the "cpp" command has no
direct connection to the ANSI C compiler's preprocessing phases,
however, "cpp" need not behave in any way anyone would deem sensible
today. So whatever it does is pretty much irrelevant.

The GNU C compiler comes with its own separate preprocessor that
can be told to `conform to ancient traditional practises' (via the
`-traditional' flag). When so told, it too observes and obeys
`#'-directives only if the `#' is the first character on the line.
That means that this "cpp" command can be used on files that contain
embedded `#'-comments:

% cat foo.s
/* copyright (c) ... */
/* this file uses C comments here and there */
/* and uses #define and #include ... but also: */
# this is an assembler comment,
# not a preprocessing directive
_foo: .globl _foo
mov 4(a0), d3 # fetch some stuff
...

If Sun were to arbitrarily change the traditional "cpp" separate
program, it would break such uses. Thus, even GCC, which can be
told to conform to the Standard, can also be told specifically *not*
to conform, and the "cpp" user-level command is often (always?)
configured to act that way be default. You cannot determine the
degree of conformance of the compiler from any conformance or
lack thereof in the separate "cpp" command.
--
In-Real-Life: Chris Torek, Berkeley Software Design Inc
El Cerrito, CA, USA Domain: to...@bsdi.com +1 510 234 3167
http://claw.bsdi.com/torek/ (not always up) I report spam to abuse@.

0 new messages