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

[C/C++] Why is MAXINT doubly defined in system include files

6 views
Skip to first unread message

Marc Ferry

unread,
Oct 10, 2003, 4:43:54 AM10/10/03
to
Hello,

I have a question regarding multiple definition of macro MAXINT in HP-UX
10.20 C/C++ include files.

/usr/include/values.h defines macro MAXINT as (~HIBITI)
/usr/include/sys/param.h defines macro MAXINT as 0x7fffffff

Why is that so ?
I understand that the final value is the same.
But as my program happens to include both values.h and param.h, I get
the following error (future) with aCC:

Error (future) 129: "/usr/include/values.h", line 27 # Redefinition of
macro 'MAXINT' differs from previous definition
at ["/usr/include/sys/param.h", line 45].
#define MAXINT (~HIBITI)
^^^^^^
Warning: 1 future errors were detected and ignored. Add a '+p'
option to detect and fix them before they become fatal errors in a
future release. Behavior of this ill-formed program is not guaranteed to
match that of a well-formed program

I cannot change the libraries (which include values.h and param.h) used
by my program because I don't own them. I don't want to use compile
option +W129 because it would suppress this particular future error but
also all the others.

Is there a simple trick to avoid this error on HP-UX 10.20 ?

I noticed that the problem has been fixed on HP-UX 11i. Indeed, values.h
defines MAXINT only if it is not already defined:
#ifndef MAXINT
#define MAXINT ((int)(~(unsigned int)HIBITI))
#endif /** MAXINT **/

Thanks for your advice.
Marc Ferry

0 new messages