Xcode 3 gcc 4.2 错误:'min' 未在此范围内声明

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6012264/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:02:19  来源:igfitidea点击:

Xcode 3 gcc 4.2 error: 'min' was not declared in this scope

xcodegcc

提问by olilarkin

for some reason now and again xcode/gcc4.2 complains about

出于某种原因,xcode/gcc4.2 时不时抱怨

error: 'min' was not declared in this scope 

and the same for max

和最大值相同

it seems to happen totally randomly, even if i #define them my self at a top level

它似乎完全随机发生,即使我#define them my self at the top level

any ideas?

有任何想法吗?

edit. i think this may have started happening after i installed Xcode 4, but not sure

编辑。我认为这可能是在我安装 Xcode 4 后开始发生的,但不确定

回答by justin

(it may help to specify the language you're using...)

(它可能有助于指定您使用的语言......)

what you see could be a few things. if you are expecting this to be c++'s std::min, then you probably have a rogue using namespace std;declared in the global namespace, which is not included ahead of every file.

你看到的可能是一些东西。如果您期望这是 c++ 的std::min,那么您可能using namespace std;在全局命名空间中声明了一个流氓,它并未包含在每个文件之前。

if this is the case:

如果是这种情况:

1) delete every global using namespace stddeclaration (optional, but worthwhile).

1) 删除每个全局using namespace std声明(可选,但值得)。

2) and/or qualify minwith std::min

2)和/或限定minstd::min

回答by drekka

This sounds like you are accessing the math.h libraries or something is wrong with your install. I'd be inclined to suggest removing xcode completely including all developer tools. The read me's have instructions for doing this. Then reboot your machine and reinstall again.

这听起来像是您正在访问 math.h 库或您的安装有问题。我倾向于建议完全删除 xcode,包括所有开发人员工具。阅读我的有这样做的说明。然后重新启动机器并重新安装。