English 中文(简体)
VS 2008 to VS 2010 migration - abreak change?
原标题:VS2008 to VS 2010 migration - a breaking change?

我在把我们的C++代码从2008年VS2010移至VS2010时遇到了问题。 我迄今无法解释其原因,并将感谢您的帮助。

我们有一个习俗记忆分配器,它居住着一片。 在守则的其余部分,我们利用预处理器将拨款转用于我们的职能。 下面的简单法典在2008年版图中是正确的,但并不在2010年版面。

in:

#define free my_free
#include <string>

In VS2010 I get:

1>d:program filesmicrosoft visual studio 10.0vcincludexdebug(62): error C3861:  free : identifier not found

参照:

template<class _Ty>
    void __CLRCALL_OR_CDECL _DebugHeapDelete(_Ty *_Ptr)
    {   // delete from the debug CRT heap even if operator delete exists
    if (_Ptr != 0)
        {   // worth deleting
        _Ptr->~_Ty();
        // delete as _NORMAL_BLOCK, not _CRT_BLOCK, since we might have
        // facets allocated by normal new.
        free(_Ptr);

任何帮助或想法都将受到高度赞赏。

Moshe

最佳回答

在利用P/P办法进行一些调查之后,我发现问题的根源。

Xdebug头盔称自己是“Microsoft的蒸发支持头盔”,其行文如下:

#pragma push_macro("free")
#undef free

这显然挫败了我们重新界定它的企图。 因此,这并不是汇编者的新的东西,只是我们试图重新界定的职能而出现的不明确之处。

问题回答

根据C++ISO标准,第17.3.1.2节:

翻译单位,包括负责人,不得包含界定该负责人所宣布或界定姓名的任何宏观。 这种翻译单位也不应界定与关键词有法性相同的名称。

这意味着,在<代码>#define上,图书馆功能名称不意味着其他内容。 我猜测,这在2008年5月S-2008年才发生,但在向VS2010迁移时,编纂者提出执行建议,而这项工作并不适当。

如果你想要重新界定什么是<条码>免费<>代码/代码”,我建议通过一个更加常规的渠道,将《守则》与你自己执行C图书馆联系起来,改变违约行为。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签