Better C++ compatibility in Zorro headers

Posted By: AndrewAMD

Better C++ compatibility in Zorro headers - 02/11/23 14:00

There are many times that I use the Visual Studio debugger, so I include the Zorro headers from a Visual Studio solution.

But I've always had to edit the header files to get them to work, and again and again for every time I get the next beta. Can we permanently make a few minor changes?

contract.c and profile.c:
replace all instances of "string" with "const char*", to prevent error C2440: 'return': cannot convert from 'const char [2]' to 'string'
Posted By: Spirit

Re: Better C++ compatibility in Zorro headers - 02/14/23 16:42

I had never problems with contract.c and profile.c in my cpp files.
Posted By: AndrewAMD

Re: Better C++ compatibility in Zorro headers - 02/15/23 14:07

Here's an example:
Code
string contractLetter(int Month)
{
	switch(Month) {
	case 1: return "F";
	case 2: return "G";
	case 3: return "H";
	case 4: return "J";
	case 5: return "K";
	case 6: return "M";
	case 7: return "N";
	case 8: return "Q";
	case 9: return "U";
	case 10: return "V";
	case 11: return "X";
	case 12: return "Z";
	}
	return "";
}
Code
1>Y:\ZorroBeta\include\contract.c(313,17): error C2440: 'return': cannot convert from 'const char [2]' to 'string'
1>Y:\ZorroBeta\include\contract.c(313,17): message : Conversion from string literal loses const qualifier (see /Zc:strictStrings)

If you use Visual Studio IDE and make a new project, /Zc:strictStrings is enabled by default. I think it's good practice to keep it enabled.
© 2024 lite-C Forums