为什么在系统包含文件中双重定义MAXINT [英] Why is MAXINT doubly defined in system include files

查看:94
本文介绍了为什么在系统包含文件中双重定义MAXINT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在comp.sys.hp和comp.sys.hp.hpux中发布了这封邮件,但是没有回应。

没有回应。由于这个问题可能出现在其他操作系统上,而不是HP-UX

10.20,我在这里进行交叉转换,以期得到答案。


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


在HP-UX 10.20上的C / C ++系统包含文件中,

/usr/include/values.h将宏MAXINT定义为(~HIBITI)

/usr/include/sys/param.h将宏MAXINT定义为0x7fffffff


为什么会这样?

我知道最终值是相同的。

但是因为我的程序恰好包含了values.h和param.h,我得到

以下错误(未来)与aCC:


错误(未来)129:" / usr / include / values。 h",第27行#重新定义

宏''MAXINT''与以前的定义不同

at ["r /incr/include/sys/param.h",第45行]。

#define MAXINT(~HIBITI)

^^^^^^

警告:检测到1个未来错误并忽略。添加''+ p''

选项,以便在它们成为

未来版本中的致命错误之前检测并修复它们。这个格式错误的程序的行为不能保证

与格式良好的程序相匹配


我无法更改库(包括values.h)和param.h)我的程序使用了

因为我不拥有它们。我不想使用编译

选项+ W129,因为它会抑制这个特殊的未来错误,但

也是其他所有错误。


是否有一个简单的技巧可以避免这个错误?


我注意到问题已在HP-UX 11i上修复。实际上,values.h

只有在尚未定义时才定义MAXINT:

#ifndef MAXINT

#define MAXINT((int)( 〜(unsigned int)HIBITI))

#endif / ** MAXINT ** /


感谢您的建议。

Marc Ferry

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

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

Thanks for your advice.
Marc Ferry

推荐答案

2003年10月13日星期一13:53:07 +0200,Marc Ferry

< mf ******** @ rd.francetelecom.com>写道:
On Mon, 13 Oct 2003 13:53:07 +0200, Marc Ferry
<mf********@rd.francetelecom.com> wrote:
我已经在comp.sys.hp和comp.sys.hp.hpux中发布了这封邮件,但没有回应。由于这个问题可能出现在其他操作系统上而不是HP-UX
10.20,我在这里交叉,希望得到答案。


这个新闻组适用于与ISO标准C ++相关的问题(或C /

the crosspost)。这显然不是正确的地方,

comp.unix.programmer会更加接近。但如果你不能在惠普相关的新闻组上得到答案,你应该直接联系惠普,因为

没有其他地方可以发布这样的问题。

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

在HP上的C / C ++系统包含文件中-UX 10.20,
/ usr /include/values.h将宏MAXINT定义为(~HIBITI)
/usr/include/sys/param.h将宏MAXINT定义为0x7fffffff


MAXINT不是标准宏,标准宏是INT_MAX,来自

< limits.h> ;.

为什么会这样?
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.
This newsgroup is for issues relating to ISO standard C++ (or C for
the crosspost). This clearly isn''t the right place,
comp.unix.programmer 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 ?




大概是个bug。您有没有问过HP?


Tom



Presumably a bug. Have you asked HP?

Tom


2003年10月13日星期一13:53:07 +0200,Marc Ferry

< mf ******** @ rd.francetelecom.com>写道:
On Mon, 13 Oct 2003 13:53:07 +0200, Marc Ferry
<mf********@rd.francetelecom.com> wrote:
在C / C ++系统中包含HP-UX 10.20上的文件,
/ usr / include / value.h将宏MAXINT定义为(~HIBITI)
/usr/include/sys/param.h将宏MAXINT定义为0x7fffffff

为什么会这样?
我知道最终值是一样的。
但是作为我的程序碰巧包括values.h和param.h,我得到了以下错误(未来)与aCC:

错误(未来)129:" / usr / include / values .h",第27行#重新定义
宏''MAXINT''与以前的定义不同
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>


尼克。



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

Nick.


Nick Austin写道:
Nick Austin wrote:
< mf ******** @ rd.francetelecom.com>写道:
<mf********@rd.francetelecom.com> wrote:
在C / C ++系统中包含HP-UX 10.20上的文件,
/ usr / include / value.h将宏MAXINT定义为(~HIBITI)
/usr/include/sys/param.h将宏MAXINT定义为0x7fffffff

为什么会这样?
我知道最终值是一样的。
但是作为我的程序碰巧包括values.h和param.h,我得到了以下错误(未来)与aCC:

错误(未来)129:" / usr / include / values .h",第27行#重新定义
宏''MAXINT''与之前的定义不同
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>



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




问题:我应该把这些线放在哪里?


记住:我无法更改图书馆所做的包含,因为我没有b $ b不拥有它们(外部产品)。我怀疑values.h和

param.h包含在同一个库中。


你能更准确吗?
<无论如何,
Thx。



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.


这篇关于为什么在系统包含文件中双重定义MAXINT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆