vc9 Feature Pack Beta tr1 的一些问题
2008-03-29 09:58
225 查看
最近使用了 vc9 Feature Pack 里 tr1 一些库,但结果却让我比较失望.
一、头文件包含的问题
如果你建一个简单的console项目,如下包含
1 #include <random>
2 #include <regex>
你不会有任何问题,但当你的包含了windows.h时,就会看到output窗口里是无尽的错误与警告。
>c:/program files/microsoft visual studio 9.0/vc/include/regex(4170) : error C2589: '(' : illegal token on right side of '::'
>c:/program files/microsoft visual studio 9.0/vc/include/random(51) : warning C4003: not enough actual parameters for macro 'max'
>c:/program files/microsoft visual studio 9.0/vc/include/random(459) : warning C4003: not enough actual parameters for macro 'min'
>c:/program files/microsoft visual studio 9.0/vc/include/random(412) : error C2059: syntax error : '<L_TYPE_raw>'
......
而你直接使用boost的库时,不会有此问题.
这个问题是因 tr1 的 max、min 与 windows.h 里的冲突导致,还好有解决方案,虽然丑陋了些
1
#pragma push_macro("min")
2
#pragma push_macro("max")
3
#undef min
4
#undef max
5
#include <random>
6
#include <regex>
7
#pragma pop_macro("min")
8
#pragma pop_macro("max")
二、regex memory leak
前面的问题还不让人感觉太难受,这一个问题就让人非常恼火了。
下面简单到不能再简单的例子就能重现这个问题
1 #define _CRTDBG_MAP_ALLOC
2 #include <crtdbg.h>
3 #include <regex>
4 int _tmain(int argc, _TCHAR* argv[])
5 {
6 using namespace std::tr1;
7 std::tr1::regex rgx("<node v='(//w+)' n='(//w+)' />");
8 _CrtDumpMemoryLeaks();
9 return 0;
10 }
debug一下,下面结果是不是让你大惊失色
......
c:/program files/microsoft visual studio 9.0/vc/include/regex(1126) : {181} normal block at 0x0079A990, 16 bytes long.
Data: <<node v=' > 3C 6E 6F 64 65 20 76 3D 27 CD CD CD CD CD CD CD
{180} normal block at 0x0079A930, 32 bytes long.
Dat
a75a
a: <8< y > 38 3C 84 00 06 00 00 00 00 00 00 00 E0 A9 79 00
......
这个问题实在没兴趣去解决了,在ms没有新补丁出来前用boost::regex或是greta吧。
btw:
在 Visual C++ Team Blog -> Q&A on our TR1 implementation
(http://blogs.msdn.com/vcblog/archive/2008/01/08/q-a-on-our-tr1-implementation.aspx)
也有人发现了同样的问题,下面是一个答复:
Thursday, January 24, 2008 7:30 PM by Stephan T. Lavavej [MSFT]
# re: Q&A on our TR1 implementation
Confirmed! regex is leaking memory. I've identified the problem and I'll file a bug about it immediately.
Stephan T. Lavavej
Visual C++ Libraries Developer
一、头文件包含的问题
如果你建一个简单的console项目,如下包含
1 #include <random>
2 #include <regex>
你不会有任何问题,但当你的包含了windows.h时,就会看到output窗口里是无尽的错误与警告。
>c:/program files/microsoft visual studio 9.0/vc/include/regex(4170) : error C2589: '(' : illegal token on right side of '::'
>c:/program files/microsoft visual studio 9.0/vc/include/random(51) : warning C4003: not enough actual parameters for macro 'max'
>c:/program files/microsoft visual studio 9.0/vc/include/random(459) : warning C4003: not enough actual parameters for macro 'min'
>c:/program files/microsoft visual studio 9.0/vc/include/random(412) : error C2059: syntax error : '<L_TYPE_raw>'
......
而你直接使用boost的库时,不会有此问题.
这个问题是因 tr1 的 max、min 与 windows.h 里的冲突导致,还好有解决方案,虽然丑陋了些
1
#pragma push_macro("min")
2
#pragma push_macro("max")
3
#undef min
4
#undef max
5
#include <random>
6
#include <regex>
7
#pragma pop_macro("min")
8
#pragma pop_macro("max")
二、regex memory leak
前面的问题还不让人感觉太难受,这一个问题就让人非常恼火了。
下面简单到不能再简单的例子就能重现这个问题
1 #define _CRTDBG_MAP_ALLOC
2 #include <crtdbg.h>
3 #include <regex>
4 int _tmain(int argc, _TCHAR* argv[])
5 {
6 using namespace std::tr1;
7 std::tr1::regex rgx("<node v='(//w+)' n='(//w+)' />");
8 _CrtDumpMemoryLeaks();
9 return 0;
10 }
debug一下,下面结果是不是让你大惊失色
......
c:/program files/microsoft visual studio 9.0/vc/include/regex(1126) : {181} normal block at 0x0079A990, 16 bytes long.
Data: <<node v=' > 3C 6E 6F 64 65 20 76 3D 27 CD CD CD CD CD CD CD
{180} normal block at 0x0079A930, 32 bytes long.
Dat
a75a
a: <8< y > 38 3C 84 00 06 00 00 00 00 00 00 00 E0 A9 79 00
......
这个问题实在没兴趣去解决了,在ms没有新补丁出来前用boost::regex或是greta吧。
btw:
在 Visual C++ Team Blog -> Q&A on our TR1 implementation
(http://blogs.msdn.com/vcblog/archive/2008/01/08/q-a-on-our-tr1-implementation.aspx)
也有人发现了同样的问题,下面是一个答复:
Thursday, January 24, 2008 7:30 PM by Stephan T. Lavavej [MSFT]
# re: Q&A on our TR1 implementation
Confirmed! regex is leaking memory. I've identified the problem and I'll file a bug about it immediately.
Stephan T. Lavavej
Visual C++ Libraries Developer
相关文章推荐
- VC 和 MFC 的一些常见问题
- 最近几天进度有一些慢,主要时间花费在如何在vc7.0中添加消息映射的问题上。
- VC6工程转VC10可能会遇到的一些问题
- 使用Sqlite的一些简单问题[VC]
- VC编译OpenSSL的一些问题记录
- VC编译\链接\运行:包含文件、包含库lib、包含动态库dll的一些问题
- VC 和 MFC 的一些常见问题
- 对VC++一些常见问题的整理
- VC使用中一些常见问题
- 【技术贴】MFC classview类视图消失的解决办法||一些常见的VC 2B问题
- vc9 Feature Pack Beta tr1 的一些问题
- VC和MFC的一些常见问题
- 对VC 一些常见问题的整理
- VC6.0 动态库或控件代码移植到VC2010一些异常问题
- VC++中的一些调试方面的问题
- 关于VC、MFC和ACCESS的一些使用问题
- VC 2005的一些细节问题
- 关于孙鑫VC++ 第六章的一些问题
- VC中出现的一些小问题的解决办法
- VC使用中一些常见问题