Newsgroups: comp.lang.c
Path: utzoo!utgpu!jarvis.csri.toronto.edu!dgp.toronto.edu!flaps
From: flaps@dgp.toronto.edu (Alan J Rosenthal)
Subject: Re: Pragmas
Message-ID: <1988Jan3.162343.1697@jarvis.csri.toronto.edu>
Organization: University of Toronto
References: <8801021358.AA15890@decwrl.dec.com> <504@cresswell.quintus.UUCP>
Date: Sun, 3-Jan-88 16:23:42 EST


ok@quintus.UUCP (Richard A. O'Keefe) writes:
 >Now, is #pragma something which forces the preprocessor to be strongly
 >coupled to the compiler, or not?  Well, if #pragma can be used to
 >declare properties of identifiers, either the preprocessor has to be
 >built into the compiler or else it has to write something into its
 >output stream which recodes the information and the compiler has to
 >reparse it.  In this latter case, there is a strong coupling between
 >the preprocessor and its particular compiler, because they have to
 >agree on how the pragma information is recoded.

How about having the preprocessor just pass them through?  The compiler
and the preprocessor already agree on how some lines beginning with #
are passed through, namely the "# line file" lines.  Just typing
"/lib/cpp" gives me one.  /lib/cpp will also pass them through.

 >The trouble with declaring properties of identifiers in the preprocessor
 >is the interaction of those declarations with C's scope rules.  Suppose
 >I say
 >
 >	int fred;			/* 1 */
 >	void jim()
 >	#pragma device_register fred
 >	    {
 >		static int fred;	/* 2 */
 >		...
 >
 >Which fred was affected?  I can think of at least four different
 >interpretations, and each of them is "natural" and "obvious" given
 >a different method of coupling the preprocessor and compiler.

After ANSI standard C hits the streets, when you type "man cc", it will
probably have a section describing pragmas, or at least it should.  It
will say something like "'#pragma device_register id' means that the
next occurrence of 'id' is a device register".  Or wherever it was you
learned of the pragma's meaning in the first place.  No problem.

Two further comments on this:
    1. that's a terrible construct anyway.
    2. I can't think of your three other "natural" interpretations.

-- 
"Bill Joy uses EMACS."  - D. Hugh Redelmeier
