[comp.sys.hp] spectrum or is it SPECTRUM???

jeffh@weycord.WEYCO.COM (05/22/88)

I'm in the process of porting a little code from the 350 to the
825/35. Well, I ran into one small snag. My code is a digital
signal processing library and I deal with "spectrum"s quite a
bit. Anyway, The compiler complained every time I called a 
spectrum a spectrum. 

The project name for the s800 is "spectrum" and I like my 
spectrums called spectrum(s). Cpp changes "spectrum" to "1"
and the compiler complains "unexpected 1". Don't think "spectrum"
is a key word in "C"??

Oh ya, a while back I tried to port the same code and didn't
have any luck at all! The new rev of HP-UX on the s800 is
much more compatible with HP-UX than the last one.

bye

Jeff Harrell
hpubvwa!weycord!jeffh

bd@hpsemc.HP.COM (bob desinger) (05/24/88)

> Cpp changes "spectrum" to "1"
> and the compiler complains "unexpected 1".

Please post some example code.  I'll run it through the mill here and
let you know what I find.

-- bd

joe@hpurnca.HP.COM (joe freeman ) (05/24/88)

In article <6430009@weycord.WEYCO.COM> jeffh@weycord.WEYCO.COM writes:
>
>I'm in the process of porting a little code from the 350 to the
>825/35. Well, I ran into one small snag. My code is a digital
>signal processing library and I deal with "spectrum"s quite a
>bit. Anyway, The compiler complained every time I called a 
>spectrum a spectrum. 
>
>The project name for the s800 is "spectrum" and I like my 
>spectrums called spectrum(s). Cpp changes "spectrum" to "1"
>and the compiler complains "unexpected 1". Don't think "spectrum"
>is a key word in "C"??

I believe that 'spectrum' is one of the predefined symbols used by the 
preprocessor so people can block out their code with 'ifdef's.  You will
find other symbols that are used, such as 'hpux' 'vax' 'unix'....  They
are normally used to conditionally compile blocks of code depending on what
machine it is on.  You should either call your local SE or the response 
center if you think a change request should be filed.

<joe freeman>

tsu@hpcupt1.HP.COM (Stanley Tsu) (05/25/88)

Jeff Harrell writes:
>                               Cpp changes "spectrum" to "1"
> and the compiler complains "unexpected 1". 

Jeff, the solution is simple: use the -U option of cc(1) to remove 
the pre-defined definition of a name.

Although "spectrum" is not a keyword, it is pre-defined for releases
up to 3.0.

Thanks go to Tim Pasek in the Computer Languages Lab who had the right
answer.

pasek@hpcltim.HP.COM (Tim Pasek) (05/25/88)

cpp on the s800 has a number of predefined symbols, including, but
not limited to hpux, unix, hp9000s800, and spectrum.  That is, cpp will
textually substitute '1' (for TRUE) for each of these predefines.

If a user program must use any predefined symbol in a context other
than conditional compilation (for example, using spectrum as an
identifier), he must compile his program with -Uspectrum, which has the
effect of removing spectrum from the table of predefines.

Note: for UX3.0, 'spectrum' will no longer be predefined; 'hppa' will
      take its place. This will be true for the XL1.2 C compiler too.

zs01+@andrew.cmu.edu (Zalman Stern) (05/25/88)

You can try adding a "-Uspectrum" flag to the C compiler command line. This
should tell the C preprocessor not to define the token "spectrum".

The preprocessor define should probably be changed to something which is not a
word in the English language. (Preferably something prefixed with "hp".) On the
other hand, HP probably has a ton of code that would have to be "fixed" in the
process.

Sincerely,
Zalman Stern
Internet: zs01+@andrew.cmu.edu     Usenet: I'm soooo confused...
Information Technology Center, Carnegie Mellon, Pittsburgh, PA 15213-3890

morrell@hpsal2.HP.COM (Michael Morrell) (05/25/88)

/ hpsal2:comp.sys.hp / pasek@hpcltim.HP.COM (Tim Pasek) / 12:46 pm  May 24, 1988 /
cpp on the s800 has a number of predefined symbols, including, but
not limited to hpux, unix, hp9000s800, and spectrum.  That is, cpp will
textually substitute '1' (for TRUE) for each of these predefines.
----------

Excuse my ignorance, but where is the list of these predefined symbols
documented?

  Michael

mlight@hpiacla.HP.COM (Mike Light ) (05/25/88)

> The compiler complained every time I called a 
> spectrum a spectrum. 

> The project name for the s800 is "spectrum" and I like my 
> spectrums called spectrum(s). Cpp changes "spectrum" to "1"
> and the compiler complains "unexpected 1". Don't think "spectrum"
> is a key word in "C"??

I don't know why, but "spectrum" comes pre-defined as the constant 1
in /lib/cpp on the 800's.  Fortunately it is easy to get rid of:

When compiling:      cc -Uspectrum etc...

or in source code:   #undef spectrum   /* Zap that mama! */

Let us know how it works!  -- Mike Light.

-----------------------------------------------------------------------
 Mike Light  HP Ind. Applications Center - {world}!hpda!hpiacla!mlight
-----------------------------------------------------------------------

rml@hpfcdc.HP.COM (Bob Lenk) (05/27/88)

> Excuse my ignorance, but where is the list of these predefined symbols
> documented?

On cpp(1), under the description of the -U option.  Admittedly this
isn't the most helpful place for someone encountering this situation.
It is useful in explaining what -U is good for.

They may be documented somewhere else as well.

		Bob Lenk
		{ihnp4, hplabs}!hpfcla!rml
		rml%hpfcla@hplabs.hp.com

bd@hpsemc.HP.COM (bob desinger) (05/27/88)

> where is the list of these predefined symbols documented?

In the man page for cpp(1).
-- bd

bd@hpsemc.HP.COM (bob desinger) (05/27/88)

> > where is the list of these predefined symbols documented?
> In the man page for cpp(1).

Steve Harrold pointed out by mail that "spectrum" is never mentioned
in cpp(1).  He's right.  The man page covers its neck, however, when
it alludes that there may be other symbols defined but not mentioned.

The SVID doesn't mention anything about predefined symbols, even
passing up a chance to belabor the obvious through a mention of
"unix."  The 4.2BSD and 4.3 manuals don't even have a separate cpp
page, the information being lumped together on the cc(1) page.
The most telling description is in _Portable_C_and_Unix_System_
_Programming_ by J. R. Lapin, under cpp:  "This utility is present
everywhere but documented almost nowhere."

-- bd