【发布时间】:2012-09-08 17:52:22
【问题描述】:
在 Visual Studio 2012 中,我无法将某些名称声明为全局标识符,因为它们已在 math.h 中声明。遗留问题使我不方便重命名源代码中的标识符。除了重命名还有什么选择?
#include "stdafx.h"
// iostream includes math.h which declares the following
_CRT_NONSTDC_DEPRECATE(_y1) _CRTIMP double __cdecl y1(_In_ double _X);
int y1; // error - y1 is already declared
void Main()
{
return;
}
额外问题:Visual Studio 2012 是否以一致的方式处理此问题?
【问题讨论】:
-
您确定
iostream包含math.h而不是cmath?确保你不是using namespace std。 -
iostream 最终包含 cmath,其中直接包含 math.h。
-
不,
cmath保证在std命名空间中包含math.h。 -
确实我是
using namespace std。你提示我阅读stackoverflow.com/questions/1452721/…。我现在可以看出我是一个误入歧途的 C 程序员,没有理会命名空间课程。现已更正。 -
您要我发布一个答案让您接受吗?
标签: c++ visual-studio namespaces standards-compliance