[comp.unix.questions] I can't find a good definition anywhere...

bph@buengc.BU.EDU (Blair P. Houghton) (05/10/89)

In article <FLEE.89May8171524@shire.cs.psu.edu> flee@shire.cs.psu.edu (Felix Lee) writes:
>Here's an extraordinarily silly idea for <default.h>.  Since the list
>
>Now, being able to say something like #pragma dumpdefines at an
>arbitrary point would be interesting.

Here's an extraordinarily neophytic question:

	What does a #pragma _do_, anyway?

Tain't the C (nor CPP) I'm used to.

				--Blair
				  "Back in the 20's, when I had
				   to walk to school four--no, FIVE--
				   miles in the snow, and the only
				   keywords in C were 'if' and 'struct'..."

karl@haddock.ima.isc.com (Karl Heuer) (05/10/89)

(Followups to comp.std.c; this is not a unix question.)

This guy walks into a bar with 500 #pragma's.  In article <2810@buengc.BU.EDU>
the bartender says,
>What does a #pragma _do_, anyway?

So the guy says, "Anything it wants!"
(With apologies to any 500# gorillas in the audience.)

Seriously, though, #pragma is the universal escape to allow implementors to
do the sorts of things that they just *have* to add to the language (e.g.
`#module' or `#ident'), in such a way that it won't interfere with other ANSI-
conforming implementations.

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint
(Oh, wow!  I actually used `#' as a pound sign!)

henry@utzoo.uucp (Henry Spencer) (05/10/89)

In article <2810@buengc.BU.EDU> bph@buengc.bu.edu (Blair P. Houghton) writes:
>	What does a #pragma _do_, anyway?

Whatever the compiler feels like.

Really.  It's an explicitly implementation-dependent "instructions to the
compiler" directive.
-- 
Mars in 1980s:  USSR, 2 tries, |     Henry Spencer at U of Toronto Zoology
2 failures; USA, 0 tries.      | uunet!attcan!utzoo!henry henry@zoo.toronto.edu

jbu@sfsup.UUCP (+Urban J.) (05/12/89)

In article <2810@buengc.BU.EDU> bph@buengc.bu.edu (Blair P. Houghton) writes:
>	What does a #pragma _do_, anyway?
>

I've only seen #pragma used the in following context:  #pragma pack(n)
This is used to create structs whose layout is compatible with other machines.

On UNIX System V/386 Release 3.2 (The Merged UNIX/XENIX Product) the CSDS 4.1.5
uses this to make some structures compatible with 80286 chip layout.  So that
AT&T PC 6300+ UNIX Programs and XENIX 286 programs can all read the same structures
in the correct order (as the 80386 creates/writes/reads 'em).

Sincerely,
John Ben Urban

dmk@pilot.njin.net (David Katinsky) (05/12/89)

In my [brief] experience with pragmas, they were used to tweak the compiler
behavior.


					dmk
-- 
			      David M. Katinsky
			      
	       dmk@pilot.njin.net 	{wherever}!rutgers!dmk