qt项目 qt creator项目由插件自动转换成的vs2015项目,为了发布少带些dll ,切换成vs2013项目,在更改了一些vs2013不支持的c++新标准写法之后,release可正常编过,但是debug报错,具体如下

vs 报错:

DataManager.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(122): error C2665: “std::locale::facet::operator new”: 2 个重载中没有一个可以转换所有参数类型
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(125): 可能是“void *std::locale::facet::operator new(size_t,const std::_DebugHeapTag_t &,char *,int)”
1>          尝试匹配参数列表“(size_t, const std::_DebugHeapTag_t, const char [71], int)”时
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(758): error C2665: “operator new[]”: 5 个重载中没有一个可以转换所有参数类型
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xdebug(37): 可能是“void *operator new[](size_t,const std::_DebugHeapTag_t &,char *,int) throw(...)”
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\crtdbg.h(1080): 或       “void *operator new[](size_t,int,const char *,int)”
1>          尝试匹配参数列表“(unsigned int, const std::_DebugHeapTag_t, const char [71], int)”时
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(794): error C2665: “operator new[]”: 5 个重载中没有一个可以转换所有参数类型
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xdebug(37): 可能是“void *operator new[](size_t,const std::_DebugHeapTag_t &,char *,int) throw(...)”
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\crtdbg.h(1080): 或       “void *operator new[](size_t,int,const char *,int)”
1>          尝试匹配参数列表“(unsigned int, const std::_DebugHeapTag_t, const char [71], int)”时
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(1652): error C2665: “std::locale::facet::operator new”: 2 个重载中没有一个可以转换所有参数类型
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(125): 可能是“void *std::locale::facet::operator new(size_t,const std::_DebugHeapTag_t &,char *,int)”
1>          尝试匹配参数列表“(unsigned int, const std::_DebugHeapTag_t, const char [71], int)”时
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(1887): error C2665: “std::locale::facet::operator new”: 2 个重载中没有一个可以转换所有参数类型
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(125): 可能是“void *std::locale::facet::operator new(size_t,const std::_DebugHeapTag_t &,char *,int)”
1>          尝试匹配参数列表“(unsigned int, const std::_DebugHeapTag_t, const char [71], int)”时
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(2473): error C2665: “std::locale::facet::operator new”: 2 个重载中没有一个可以转换所有参数类型
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(125): 可能是“void *std::locale::facet::operator new(size_t,const std::_DebugHeapTag_t &,char *,int)”
1>          尝试匹配参数列表“(unsigned int, const std::_DebugHeapTag_t, const char [71], int)”时
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(2669): error C2665: “std::locale::facet::operator new”: 2 个重载中没有一个可以转换所有参数类型
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(125): 可能是“void *std::locale::facet::operator new(size_t,const std::_DebugHeapTag_t &,char *,int)”
1>          尝试匹配参数列表“(unsigned int, const std::_DebugHeapTag_t, const char [71], int)”时
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(2896): error C2665: “std::locale::facet::operator new”: 2 个重载中没有一个可以转换所有参数类型
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(125): 可能是“void *std::locale::facet::operator new(size_t,const std::_DebugHeapTag_t &,char *,int)”
1>          尝试匹配参数列表“(unsigned int, const std::_DebugHeapTag_t, const char [71], int)”时
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xiosbase(455): error C2665: “operator new”: 5 个重载中没有一个可以转换所有参数类型
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xdebug(33): 可能是“void *operator new(size_t,const std::_DebugHeapTag_t &,char *,int) throw(...)”
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\crtdbg.h(1072): 或       “void *operator new(size_t,int,const char *,int)”
1>          尝试匹配参数列表“(unsigned int, const std::_DebugHeapTag_t, const char [72], int)”时
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xiosbase(537): error C2665: “operator new”: 5 个重载中没有一个可以转换所有参数类型
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xdebug(33): 可能是“void *operator new(size_t,const std::_DebugHeapTag_t &,char *,int) throw(...)”
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\crtdbg.h(1072): 或       “void *operator new(size_t,int,const char *,int)”
1>          尝试匹配参数列表“(unsigned int, const std::_DebugHeapTag_t, const char [72], int)”时
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xiosbase(591): error C2665: “operator new”: 5 个重载中没有一个可以转换所有参数类型
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xdebug(33): 可能是“void *operator new(size_t,const std::_DebugHeapTag_t &,char *,int) throw(...)”
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\crtdbg.h(1072): 或       “void *operator new(size_t,int,const char *,int)”
1>          尝试匹配参数列表“(unsigned int, const std::_DebugHeapTag_t, const char [72], int)”时
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocnum(65): error C2665: “operator new[]”: 5 个重载中没有一个可以转换所有参数类型
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xdebug(37): 可能是“void *operator new[](size_t,const std::_DebugHeapTag_t &,char *,int) throw(...)”
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\crtdbg.h(1080): 或       “void *operator new[](size_t,int,const char *,int)”
1>          尝试匹配参数列表“(unsigned int, const std::_DebugHeapTag_t, const char [71], int)”时

----------------------------------------------------------------------------------------------------------------------------------

查了下 error C2665: “operator new[]”: 5 个重载中没有一个可以转换所有参数类型,对应的c2665 有如下两个解决方案:
from:http://blog.csdn.net/machh/article/details/43450725
解决方法1:注释掉以下代码:
#ifdef _DEBUG
#define new DEBUG_NEW
#endif

解决方法2:
将:代码中的#include <vector>移到stdafx.h的开头,也就是#program once的后面。

但并没有解决我的问题。

对比正常工程 发现c/c++  ->所有选项-->附加选项 多了-Zc:strictStrings ,应该是qt转换插件自动加的,去掉就可以正常编译了。

解释见:https://msdn.microsoft.com/zh-cn/library/dn449508.aspx

若要了解有关 Visual Studio 2017 RC 的最新文档,请参阅 Visual Studio 2017 RC 文档

指定后,编译器要求通过使用字符串文本初始化的指针符合严格的 const 限定。

 
 
/Zc:strictStrings[-]  

如果指定了 /Zc:strictStrings,则编译器针对字符串文本(如类型“const char 的数组”或“const wchar_t 的数组”,具体取决于声明)强制执行标准 C++ const 限定。 字符串文本不可变,并且尝试修改一个字符串文本的内容将导致在运行时出现访问冲突错误。 必须将字符串指针声明为 const 以通过使用字符串文本将其初始化,或使用显式 const_cast 以初始化非 const 指针。 或者默认情况下,如果指定了 /Zc:strictStrings-,则编译器不会针对通过使用字符串文本初始化的字符串指针强制执行标准 C++ const 限定。

使用 /Zc:strictStrings 选项来阻止编译错误代码。 此示例显示一个简单声明错误如何在运行时导致崩溃:

 
// strictStrings_off.cpp
// compile by using: cl /W4 strictStrings_off.cpp
int main() {
wchar_t* str = L"hello";
str[2] = L'a'; // run-time error: access violation
}

/Zc:strictStrings 处于启用状态时,相同的代码将报告 str 声明中的错误。

 
// strictStrings_on.cpp
// compile by using: cl /Zc:strictStrings /W4 strictStrings_on.cpp
int main() {
wchar_t* str = L"hello"; // error: Conversion from string literal
// loses const qualifier
str[2] = L'a';
}

如果使用 auto 声明字符串指针,则编译器将为你创建正确的 const 指针类型声明。 尝试修改 const 指针的内容将由编译器报告为错误。

 说明

Visual Studio 2013 中的 Visual C++ 中的标准 C++ 库不支持调试生成中的 /Zc:strictStrings 编译器选项。 如果在你的生成输出中看到多个 C2665 错误,则可能由此原因造成。

有关 Visual C++ 中的一致性问题的详细信息,请参阅非标准行为

在 Visual Studio 开发环境中设置此编译器选项

  1. 打开项目的“属性页”对话框。 有关详细信息,请参见使用项目属性

  2. 选择 C/C++ 文件夹。

  3. 选择“命令行”属性页。

  4. 修改“附加选项”属性以包含 /Zc:strictStrings,然后选择“确定”

error C2665: “std::locale::facet::operator new”: 2 个重载中没有一个可以转换所有参数类型的更多相关文章

  1. 【Problem solved】 error C2665: “loadimage”: 2 个重载中没有一个可以转换所有参数类型

    选择“项目”菜单->项目属性->配置属性->常规->字符集,改为“未设置”即可.

  2. 错误C2665: “AfxMessageBox”: 2 个重载中没有一个可以转换所有参数类型

    第一种方法: AfxMessageBox( "Simple   message   box. ");如果先定义一个CString   变量,再赋值就没问题CString   sTe ...

  3. std::locale与boost::locale的学习

    1. 什么是facet, locale facet ['fæsɪt]的原意,是宝石切割出来的一个平面. locale[ləʊˈkæl],表示本地化, locale the container that ...

  4. 编译错误 error C2451: “std::_Unforced”类型的条件表达式是非法的

    part 1 编译器 vs2015 VC++. 完整的错误信息粘贴如下: d:\program files (x86)\microsoft visual studio 14.0\vc\include\ ...

  5. [问题解决] locale::facet::_S_create_c_locale name not valid

    错误: exception in initAndListen: 14043 clear tmp files caught exception exception: locale::facet::_S_ ...

  6. Caffe 编译后 make runtest 出现locale::facet::_S_create_c_locale 错误

    You might need to append LC_ALL="en_US.UTF-8" to file: /etc/default/locale and reboot your ...

  7. usr/include/c++/6.4.1/bits/stl_relops.:67: Parse error at "std"

    问题描述: 1.编译某qt工程的32位架构二进制包时,出现了上面错误,具体错误信息如下 qmake-qt5 -o ProductLicense/Makefile ProductLicense/Prod ...

  8. error C2556: 'const char &MyString::operator [](int)' : overloaded function differs only by return type from 'char &MyString::operator [](int)'

    char & operator[](int i);const char & operator[](int i);/*const char & operator(int i);* ...

  9. C++的中英文字符串表示(string,wstring),使用wcout.imbue(std::locale("chs"));本地化解析编码

    在C++中字符串类的string的模板原型是basic_string template <class _Elem, class traits = char_traits<_Elem> ...

随机推荐

  1. VS中常用的环境变量

    环境变量名 含义 $(SolutionDir) 解决方案目录:即.sln文件所在路径 $(ProjectDir) 项目根目录:, 即.vcxproj文件所在路径 $(Configuration) 当前 ...

  2. Windows应用程序运行权限设置

    在Vista以后的windows版本中,有些时候需要提升编译后生成程序的权限,即希望让生成的程序以管理员身份运行.虽然在一般情况下,可以使用鼠标右键选择的方式来强行以管理员身份运行,但它并没有屏蔽普通 ...

  3. CodeFirst中DbContext动态添加DbSet

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...

  4. Python_selenium之窗口切换

    Python_selenium之窗口切换 1. 运用switch_to.window()方法来进行窗口切换 2. 思路拆分: 浏览器获取百度贴吧网址 点击定位到一个元素,获取当前的句柄 获得所有的句柄 ...

  5. Duilib教程-自动布局1

    我们要实现一个带标题栏和状态栏的程序,同时要支持拉伸,即包括最小化.最大化,图如下: XML: <?xml version="1.0" encoding="utf- ...

  6. ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]

    今天第一次遇到Failed to start component [StandardEngine[Catalina].StandardHost[localhost].错误,并且在错误提示的后半段出现了 ...

  7. DotNet软件开发框架

    这是我4月份发在donews博客上的文章,现在都转到博客园来,风满袖希望进一步阐述你的架构,我就将这篇文章转移到博客园.原文:http://blog.donews.com/shanyou/archiv ...

  8. 51NOD 1013(3的幂的和)

    题目链接:传送门 题目大意:求(3^0+3^1+3^2+3^3+...+3^n)%1e9的值 题目思路:乘法逆元裸题 #include <iostream> #include <cs ...

  9. Java String.replaceAll() 与后向引用(backreference)

    问题 昨天看到一篇博文,文中谈到一道 Java 面试题: 给定一字符串,若该字符串中间包含 "*",则删除该 "*":若该字符串首字符或尾字符为 "* ...

  10. java.lang.IllegalArgumentException: Failed to decrypt.

    加密失败. 附加信息: org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Co ...