47.VC(custom)-string头文件与cstring头文件
2012-08-29 11:31
176 查看
首先说string的头文件
1、<string>
包装了std的C++头文件
2、<string.h>
旧的C头文件
3、<cstring.h>
旧C头文件的std版本,切记,这不是cstring的头文件
详见effective c++ 的第49条
再说cstring的头文件
注:VC9编译环境下
1、<atlstr.h>
非MFC版本,控制台程序就用这个
<afx.h>、<afxcoll.h>都可以。//要在项目->属性->常规里设置为使用MFC(动/静).
2、<afxstr.h>// only be used in MFC projects.
MFC版本,需要链接MFC的dll或静态库。网上很多人说要包含<afx.h>,<afx.h>包含的东西就比较多了CObject及其派生类,还有文件类、时间类、异常类、字符串类等等(700多行的位置包含了afxstr.h),如果仅仅需要cstring的话,包含<afxstr.h>就够了。
<afx.h>中的预处理
#ifdef _DLL
#ifndef _AFXDLL
#error Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
#endif
#endif
<afxstr.h>中的预处理
#ifndef _AFX
#error afxstr.h can only be used in MFC projects. Use atlstr.h
#endif
注意上面的#error,大意就是这个头文件是在MFC工程里用的。
1、<string>
包装了std的C++头文件
2、<string.h>
旧的C头文件
3、<cstring.h>
旧C头文件的std版本,切记,这不是cstring的头文件
详见effective c++ 的第49条
再说cstring的头文件
注:VC9编译环境下
1、<atlstr.h>
非MFC版本,控制台程序就用这个
<afx.h>、<afxcoll.h>都可以。//要在项目->属性->常规里设置为使用MFC(动/静).
2、<afxstr.h>// only be used in MFC projects.
MFC版本,需要链接MFC的dll或静态库。网上很多人说要包含<afx.h>,<afx.h>包含的东西就比较多了CObject及其派生类,还有文件类、时间类、异常类、字符串类等等(700多行的位置包含了afxstr.h),如果仅仅需要cstring的话,包含<afxstr.h>就够了。
<afx.h>中的预处理
#ifdef _DLL
#ifndef _AFXDLL
#error Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
#endif
#endif
<afxstr.h>中的预处理
#ifndef _AFX
#error afxstr.h can only be used in MFC projects. Use atlstr.h
#endif
注意上面的#error,大意就是这个头文件是在MFC工程里用的。
相关文章推荐
- String头文件与CString头文件
- string头文件与cstring头文件
- 转载:[VC/C++]CString,int,string,char*之间的转换
- VC编程CString、int、string、char*相互转换
- VC2010中怎样添加头文件路径(外来的头文件)还有lib库
- VC CString,int,string,char*之间的转换
- C++中关于头文件<string>、<string.h>和<cstring>的区别
- string 与CString头文件包含差异
- VC之CString,wchar_t,int,string,char*之间的转换(转帖)
- CString和string头文件
- VC 中类型转换(CString,TCHAR*,string)
- 在VC9.0中实现C++模板类头文件和实现文件分离的方法
- [VC/C++]CString,int,string,char*之间的转换
- string和cstring头文件的区别
- 【编程拾遗】VC++中LPCTSTR、CString、char *、string之间的相互转换
- 头文件 string.h cstring string 区别
- VC_ 中类型转换(CString_TCHAR_string)
- VC之CString,wchar_t,int,string,char*之间的转换
- 头文件 string.h cstring string 区别
- VS2010 VC++ 无法打开包括文件 hidsdi.h + USB通讯需使用的头文件和库