英文:
How to allow type conversions in Visual Studio C++
问题
I'm working with an old C++ application that has been certified for a certain system. So, I'm not allowed to make any changes. However, I have to make a new build in Visual Studio 2019. I am running into a lot of conversions issues like this.
void sendMsg(char* msg)
{
// code
}
int main()
{
sendMsg("hello");
}
[Error (active) E0167 argument of type "const char" is incompatible with parameter of type "char".]
在Visual Studio中是否有可用于允许这些类型的转换发生的设置?
英文:
I'm working with an old C++ application that has been certified for a certain system. So, I'm not allowed to make any changes. However, I have to make a new build in Visual Studio 2019. I am running into a lot of conversions issues like this.
void sendMsg(char* msg)
{
// code
}
int main()
{
sendMsg("hello");
}
> [Error (active) E0167 argument of type "const char" is incompatible with parameter of type "char".]
Is there a setting in Visual Studio I can use to allow these types of conversions to happen?
答案1
得分: 0
感谢,@Swift!使用/permissive就像魔法一样奏效。
我可能应该提供更多细节。
1)正如我所说,我不能改变代码的选项。
2)我必须在Visual Studio 2019中构建它。
3)原始代码是为一个更早版本的C++编写的。
我之前没有提到的要点是:
1)这是一个完整且正常运行的Linux应用程序。
a)由于应用程序已经完成,不会进行新的开发,
因此我不关心错误检查。
2)我需要在VS中构建应用程序的Windows版本。
3)代码库包含数千个文件。更改它们所有将超出我的时间预算。
4)可能有一个新版本的Linux构建。我不想引入可能导致问题的代码库,
先前是稳定的。我也不想维护两个代码库。
英文:
Thanks, @Swift! Using /permissive worked like a charm.
I probably should have given a few more details.
- As I said, I don't have the option of changing the code.
- I have to get it built in Visual Studio 2019.
- The original code was written for a much older version of C++
The points that I did not mention before were:
-
This was a complete and functioning Linux application.
a) Since the application was complete, no new development
was going to happen. Therefore, I did not care about
error checking. -
I needed to build a Windows version of the application in VS.
-
The code base contained thousands of files. Changing all of them
would have exceeded my time budget. -
There may be a new version of the Linux build. I did not want
to introduce possible issues with a code base that was previously
stable. I also didn't want to maintain two code bases.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论