473,778 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why is MAXINT doubly defined in system include files

I already posted this mail in comp.sys.hp and comp.sys.hp.hpu x but had
no response. As this problem might be present on other OSes than HP-UX
10.20, I crosspost it here, in the hope of getting an answer.

*************** **********

In C/C++ system include files on HP-UX 10.20,
/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 ?

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)(~(unsign ed int)HIBITI))
#endif /** MAXINT **/

Thanks for your advice.
Marc Ferry

Nov 13 '05 #1
11 20904
On Mon, 13 Oct 2003 13:53:07 +0200, Marc Ferry
<mf********@rd. francetelecom.c om> wrote:
I already posted this mail in comp.sys.hp and comp.sys.hp.hpu x but had
no response. As this problem might be present on other OSes than HP-UX
10.20, I crosspost it here, in the hope of getting an answer.
This newsgroup is for issues relating to ISO standard C++ (or C for
the crosspost). This clearly isn't the right place,
comp.unix.progr ammer would be slighly closer. But if you can't get an
answer on HP related newsgroups, you should contact HP directly, since
there's no where else to post such questions.
************** ***********

In C/C++ system include files on HP-UX 10.20,
/usr/include/values.h defines macro MAXINT as (~HIBITI)
/usr/include/sys/param.h defines macro MAXINT as 0x7fffffff
MAXINT isn't a standard macro, the standard macro is INT_MAX, from
<limits.h>.
Why is that so ?


Presumably a bug. Have you asked HP?

Tom
Nov 13 '05 #2
On Mon, 13 Oct 2003 13:53:07 +0200, Marc Ferry
<mf********@rd. francetelecom.c om> wrote:
In C/C++ system include files on HP-UX 10.20,
/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


#include <values.h>
#undef MAXINT
#include <sys/param.h>

Nick.

Nov 13 '05 #3
Nick Austin wrote:
<mf********@rd. francetelecom.c om> wrote:
In C/C++ system include files on HP-UX 10.20,
/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


#include <values.h>
#undef MAXINT
#include <sys/param.h>


Question: Where should I put these lines ?

Remember: I cannot change the includes done by the libraries because I
don't own them (external product). And I doubt that both values.h and
param.h includes are in the same library.

Could you be more precise ?

Thx anyway.

Nov 13 '05 #4
tom_usenet wrote:
<mf********@rd. francetelecom.c om> wrote:
I already posted this mail in comp.sys.hp and comp.sys.hp.hpu x but had
no response. As this problem might be present on other OSes than HP-UX
10.20, I crosspost it here, in the hope of getting an answer.


This newsgroup is for issues relating to ISO standard C++ (or C for
the crosspost). This clearly isn't the right place,
comp.unix.progr ammer would be slighly closer. But if you can't get an
answer on HP related newsgroups, you should contact HP directly, since
there's no where else to post such questions.


Don't you mix up with comp.std.c++ ?
************* ************

In C/C++ system include files on HP-UX 10.20,
/usr/include/values.h defines macro MAXINT as (~HIBITI)
/usr/include/sys/param.h defines macro MAXINT as 0x7fffffff

MAXINT isn't a standard macro, the standard macro is INT_MAX, from
<limits.h>.


I know that very well. I never use MAXINT in my code.
But I cannot change the libraries that include MAXINT because they are
commercial ones : I don't have the source code.
I must do with them anyway.

My question was only : is there a special (simple) trick to solve the pb ?

BTW, have a look at values.h & param.h and you'll see that MAXINT _is_
defined as a macro.
Why is that so ?


Presumably a bug. Have you asked HP?


Not yet. I am going to look for my support contract with HP (if I have one).

Thanks for your advice.
Marc

Nov 13 '05 #5
Marc Ferry <mf********@rd. francetelecom.c om> scribbled the following
on comp.lang.c:
tom_usenet wrote:
<mf********@rd. francetelecom.c om> wrote:
I already posted this mail in comp.sys.hp and comp.sys.hp.hpu x but had
no response. As this problem might be present on other OSes than HP-UX
10.20, I crosspost it here, in the hope of getting an answer.
This newsgroup is for issues relating to ISO standard C++ (or C for
the crosspost). This clearly isn't the right place,
comp.unix.progr ammer would be slighly closer. But if you can't get an
answer on HP related newsgroups, you should contact HP directly, since
there's no where else to post such questions.

Don't you mix up with comp.std.c++ ?


Assuming s/c++/c/, the answer is still no. The comp.lang.c{++}
newsgroups are for discussing programming in the ISO C{++} languages.
The comp.std.c{++} newsgroups, OTOH, are for discussing the *actual
standard documents*.
For example:
Typical comp.lang.c question: "Is it safe to call free() with a NULL
argument?"
Typical comp.std.c question: "The C standard says SHALL in item
28.3.5 of chapter 19. Shouldn't that be SHOULD?"

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Make money fast! Don't feed it!"
- Anon
Nov 13 '05 #6
"Marc Ferry" <mf********@rd. francetelecom.c om> wrote in message
news:bm******** *@news.rd.franc etelecom.fr...
Nick Austin wrote:
<mf********@rd. francetelecom.c om> wrote:
In C/C++ system include files on HP-UX 10.20,
/usr/include/values.h defines macro MAXINT as (~HIBITI)
/usr/include/sys/param.h defines macro MAXINT as 0x7fffffff


#include <values.h>
#undef MAXINT
#include <sys/param.h>


Question: Where should I put these lines ?


Add the #undef somewhere between the clashing #include directives in your
own source (or header) file.

Alex
Nov 13 '05 #7

On Mon, 13 Oct 2003, Marc Ferry wrote:

In C/C++ system include files on HP-UX 10.20,
/usr/include/values.h defines macro MAXINT as (~HIBITI)
/usr/include/sys/param.h defines macro MAXINT as 0x7fffffff

The "canonical" workaround (according to Google) is simply to
change 'MAXINT' to something else in one of the headers, or add
guards like so:

#ifndef MAXINT
#define MAXINT foo
#endif

inside both of the headers.

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)(~(unsign ed int)HIBITI))
#endif /** MAXINT **/


Well, that's the fix you should use, then.
Perhaps you don't have write access to /usr/include -- in
that case, the #undef "trick" mentioned elsethread is your
best bet. But contact your sysadmin in any case, and get
him to patch those headers, so nobody else gets burnt.

-Arthur
Nov 13 '05 #8
Marc Ferry wrote:
My question was only : is there a special (simple) trick to solve the pb ?
#include <value.h>
#undef MAXINT
#include <param.h>

Maybe, but only maybe.

BTW, have a look at values.h & param.h and you'll see that MAXINT _is_
defined as a macro.


That might be true. I don't have those headers though.

--
Thomas

Nov 13 '05 #9
Marc Ferry escribió:
Is there a simple trick to avoid this error ?

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)(~(unsign ed int)HIBITI))
#endif /** MAXINT **/


Change your values.h in 10.20 to do the same.

Regards.
Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1315
by: Bengt Richter | last post by:
Peculiar boundary cases: >>> 2.0**31-1.0 2147483647.0 >>> int(2147483647.0) 2147483647L >>> int(2147483647L ) 2147483647 >>> >>> -2.0**31
6
2090
by: Bengt Richter | last post by:
Peculiar boundary cases: >>> 2.0**31-1.0 2147483647.0 >>> int(2147483647.0) 2147483647L >>> int(2147483647L ) 2147483647 >>> >>> -2.0**31
11
12484
by: Marc Ferry | last post by:
I already posted this mail in comp.sys.hp and comp.sys.hp.hpux but had no response. As this problem might be present on other OSes than HP-UX 10.20, I crosspost it here, in the hope of getting an answer. ************************* In C/C++ system include files on HP-UX 10.20, /usr/include/values.h defines macro MAXINT as (~HIBITI) /usr/include/sys/param.h defines macro MAXINT as 0x7fffffff
4
2932
by: dssuresh6 | last post by:
Whether browsing forward or backward can be done using a singly linked list. Is there any specific case where a doubly linked list is needed? For people who say that singly linked list allows traversal only in one direction, I would say that using appropriate loops/recursion, traversal in opposite direction is also possible. Then why the need for doubly linked list? --
8
4170
by: sudhirlko2001 | last post by:
How to swap two nodes of doubly Linklist
0
7797
by: Scott Chang | last post by:
Hi all, I have Microsoft Visual C++ .NET (2002) program that is installed on my Windows XP Professional Operating System PC. I started my project (named HelloMCPP)in the Managed C++ Application and added a DLL in the .h file to my project for printing "Hello from Managed C++!" out in my console. I did "Build" the program 'HelloMCPP' and I got 'Fatal Error LNK1561: entry point must be defined HelloMCPP'. I do not know how to define the...
6
2064
by: Sebastian Schack | last post by:
Hey everyone. Hope I'm in the right spot here... if not, please correct me. My .css starts with the definition of the body-part which looks as follows: body { background: #FFFFFF url(images/banner_spacer.png) repeat-x; font: normal small Arial, Helvetica, sans-serif; }
4
3093
kim6987
by: kim6987 | last post by:
can you please spend a little time evaluating this code. I can not run it successfully thanks :) #include<stdio.h> #include<conio.h> #include<stdlib.h> #define SIZE 10 typedef struct dlist
1
2353
by: Mahesh | last post by:
Hi Coders, I was asked to write a program to interchange numbers using doubly linked list @ Amazon. Here is the details with Code that i wrote. i/p: 1 2 3 4 5 6 7 8 .....n,n-1. o/p: 2 1 4 3 6 5 8 7.....n,n-1.
13
2089
by: Ruud | last post by:
Hallo allemaal, This is my first message to this group. Until now I mainly wrote programs in Turbo Pascal. But now I'm involved in a project were knowledge of C is needed. I'm not unfamiliar with C, but the last time I used it was maybe 8 years ago. I wrote quite some programs in TP and one goal is to translate them into C. In time I created some common, so called, units. I already
0
9632
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9471
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10302
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10136
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8958
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.