惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - 吴尔平

gtest 的彩色信息输出 + boost.test 的内存泄漏检测及定位 在低版本的 vc 中使用 vc 10.0 的新特性 使用另一个blog: http://blog.csdn.net/WuErPing scons + swig 如何在 vista 使用 Device Emulator 连接internet NSIS Kill Process (转贴) C#与一个彩票页面 - 吴尔平 - 博客园 py2exe 转换 pytetris - 吴尔平 关于模板化的friend class C# 的 random shuffle python 读取 windows event log 的简短代码 IronPython 1.0 Release Candidate (转贴 ( 据说比c实现的快1.5!) ) Visual Studio Service Pack (转贴) The 16th Annual Jolt Product Excellence Award Winners (转贴) C++/CLI FAQ (逐步整理中) C++/CLI singleton模式 (双重检测锁实现) 如何在 VS2005 的 Team Unit Testing frameworks 中测试 Native Code (C++ ) 2005 CRT memory leaks 改变 SQL Server 2000 所有对象的所有者
vc9 Feature Pack Beta tr1 的一些问题
吴尔平 · 2008-03-29 · via 博客园 - 吴尔平

 最近使用了  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.
   Data: <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