strsafe.h不能在windows.h, tchar.h, 包括很多C++的头文件,比如<map>,之前被include。否则编译的时候就会报windows.h, tchar.h, winbase.h...这些头文件中定义错误,或是重复定义。

所以,安全的做法是:

1. 在cpp文件中include <strsafe.h>,因为一般要include这个文件,都是要使用StringCch*函数,这些函数的使用一般都是在cpp中。
2. 在include的时候,要让strsafe.h在上述那些头文件之后被include


在网上搜到的资料显示,strsafe.h头文件中会把那些不安全的字符串函数全都undef,所以,strsafe不能在包含这些函数的头文件之前被include,否则就出warning了。
 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-26
  • 2021-12-12
  • 2021-10-29
  • 2021-12-26
  • 2021-09-08
  • 2022-03-10
猜你喜欢
  • 2022-01-17
  • 2021-08-20
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2021-09-30
相关资源
相似解决方案