Search code examples
c++visual-studiotype-conversion

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".]

Is there a setting in Visual Studio I can use to allow these types of conversions to happen?


Solution

  • Thanks, @Swift! Using /permissive worked like a charm.

    I probably should have given a few more details.

    1. As I said, I don't have the option of changing the code.
    2. I have to get it built in Visual Studio 2019.
    3. The original code was written for a much older version of C++

    The points that I did not mention before were:

    1. 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.

    2. I needed to build a Windows version of the application in VS.

    3. The code base contained thousands of files. Changing all of them
      would have exceeded my time budget.

    4. 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.