本文介绍了为什么在系统包含文件中双重定义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

推荐答案




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


Tom



Presumably a bug. Have you asked HP?

Tom





#include< values.h>

#undef MAXINT

#include< sys / param.h>


尼克。



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

Nick.




#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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-09 22:09