[comp.unix.aix] predefined macros and "MAXFLOAT"

rds95@leah.Albany.Edu (Robert Seals) (08/30/90)

Hello,

<math.h> defines MAXFLOAT as (*((float *) (&SFPMAX))), and SFPMAX
is an extern unsigned int. So, it's impossible to do something like

const float        lims[] = {1.0, 2.5, MAXFLOAT};

because MAXFLOAT isn't constant.

I suppose there's nothing really wrong with this, but it kinda
bugs me that it's a variable. What do YOU think? Should it
be just #defined to be the real value, or is this tricky business
better?

And another thing, I can't find anyplace (even under "Predefined Macros"
in the info explorer) what sort of groovy things are defined by the
compiler - there must be something like "AIX" or "(C) IBM Corp" or
something, eh?

rob
-- 
--------------------------------------------------------------------------------
"Unix has its weak points, but its file system is not one of them." -Chris Torek
  rob rob@asrcmv.albany.edu or rds95@leah.albany.edu or rob@dinner.albany.edu
		I have no idea what the uucp path to me is.

rds95@leah.Albany.Edu (Robert Seals) (08/30/90)

In article <3583@leah.Albany.Edu>, I wrote;

> is an extern unsigned int. So, it's impossible to do something like
> 
> const float        lims[] = {1.0, 2.5, MAXFLOAT};

Well, it turns out that "const" is perfectly OK, but "static" gets
the error message "illegal constant expression". Strange.

It seems to me that 'const' oughta be NG, and static oughta be OK.

What's da scoop?

rob
-- 
--------------------------------------------------------------------------------
"Unix has its weak points, but its file system is not one of them." -Chris Torek
  rob rob@asrcmv.albany.edu or rds95@leah.albany.edu or rob@dinner.albany.edu
		I have no idea what the uucp path to me is.

jsalter@slo.awdpa.ibm.com (08/31/90)

In article <3583@leah.Albany.Edu> rds95@leah.Albany.Edu (Robert Seals) writes:
><math.h> defines MAXFLOAT as (*((float *) (&SFPMAX))), and SFPMAX
>is an extern unsigned int. So, it's impossible to do something like
>
>const float        lims[] = {1.0, 2.5, MAXFLOAT};
>
>because MAXFLOAT isn't constant.
>
>I suppose there's nothing really wrong with this, but it kinda
>bugs me that it's a variable. What do YOU think? Should it
>be just #defined to be the real value, or is this tricky business
>better?

It's both better and worse.  Yes, you can't use it your way, but the
rationale behind it being done the way it is is that the header files can
be common across platforms and the change needs to be a file in libc.a.

Considering that AIX is supposed to span the IBM hardware -
386/6000/370 - and since they all use different number
schemes (little-endian/big-endian/370-endian :-]), there is no way
to assume the representation for this value will be the same.

>And another thing, I can't find anyplace (even under "Predefined Macros"
>in the info explorer) what sort of groovy things are defined by the
>compiler - there must be something like "AIX" or "(C) IBM Corp" or
>something, eh?

Well, if you type "cc -v file.c", it will show you the following:

	xlcentry(...,-D_IBMR2,-D_AIX,...)

This would be a good place to start.  This is also mentioned in the "Porting
4.3 BSD programs to AIX Version 3.1" document.  If you don't have this let me
know and I'll send you a copy.

>rob
>  rob rob@asrcmv.albany.edu or rds95@leah.albany.edu or rob@dinner.albany.edu


jim/jsalter  IBM AWD, Palo Alto  T465/(415)855-4427   VNET: JSALTER at AUSVMQ
Internet: ibmsupt!jsalter@uunet.uu.net         UUCP: ..!uunet!ibmsupt!jsalter 
	"Waco is a state of mind. Once you've gone there,
		you never come back" - Leo