C++ scripts

Posted By: jcl

C++ scripts - 05/18/22 10:44

The new beta version can directly invoke cl.exe and compile .cpp scripts without setting up a VC++ project. This is one of the prerequisites for a future 64 bit version with no lite-C compiler. Check it out!

https://opserver.de/down/ZorroBeta.zip
Posted By: Grant

Re: C++ scripts - 05/18/22 11:33

This is great, since I'm not a fan of Visual c++
Posted By: AndrewAMD

Re: C++ scripts - 05/18/22 14:44

Version S 2.49.1b:

*.cpp files in the Strategy folder do not appear in the drop-down list of scripts, and there is no Source\compile.bat file. Did it not make it into the current beta?
Posted By: Petra

Re: C++ scripts - 05/18/22 15:45

Check the zorro.exe file date, it should be from 12:56 today. I think the version number was not increased, so there is an older 2.49.1b from last week.
Posted By: AndrewAMD

Re: C++ scripts - 05/18/22 16:41

I downloaded it yet again, and now we're in business.

The documentation says it was designed for VC++ 2022, but I'm having no problems compiling with 2019. (Too lazy to install 2022.)
Posted By: AndrewAMD

Re: C++ scripts - 05/18/22 16:43

I think pressing the Edit button for filename.cpp attempts to open filename.c.

Also, are precompiled headers not supported? (Not a big deal.)

It would also be nice if there was a "[New C++ Script]" selection in the drop down, distinguished from "[New Lite-C Script]".

Lastly, the Help file links are not working from Notepad++ C++ out of the box, but I can fix this by changing Language to C. This could cause problems if i start writing C++ -only code, though (i.e. incompatible with C).

I might consider using Visual Studio directly to edit C++ files, even if in the Strategy folder. The intellisense works very well if you simply open up the Zorro Folder, and then from there open strategy files in subfolders. This might even be the best default behavior, to open a C++ file in Visual Studio from the Zorro folder root.

Attached picture 001.PNG
Posted By: AndrewAMD

Re: C++ scripts - 05/20/22 17:35

In Visual Studio, if you want to see red squiggly lines in Intellisense, all you have to do is add a file CppProperties.json to the root of the Zorro folder:
https://docs.microsoft.com/en-us/cp...e-code-navigation-with-cpppropertiesjson

Example content:
Code
{
	"configurations": [
		{
			"inheritEnvironments": [
				"msvc_x86"
			],
			"name": "x86-Release",
			"includePath": [
				"${env.INCLUDE}",
				"${workspaceRoot}\\**"
			],
			"defines": [
				"WIN32"
			],
			"intelliSenseMode": "windows-msvc-x86"
		}
	]
}


Attached picture 002.PNG
Posted By: QuadraQuant

Re: C++ scripts - 05/25/22 11:59

As a side note for Wine lovers, this version won't boot if visual c++ 2015+ is not installed. Use the embedded vc_redist.x6.exe or install through winetricks.
Posted By: QuadraQuant

Re: C++ scripts - 05/25/22 21:20

Originally Posted by QuadraQuant
As a side note for Wine lovers, this version won't boot if visual c++ 2015+ is not installed. Use the embedded vc_redist.x6.exe or install through winetricks.


Or you can read the relevant part of the doc. I didn't. Shame on me.
Posted By: jcl

Re: C++ scripts - 06/07/22 14:01

While you're at testing .cpp scripts, please test them also with the new 64-bit Zorro in the Zorro64 folder of today's beta version. Let me know if you encounter any problem.
Posted By: AndrewAMD

Re: C++ scripts - 06/10/22 15:05

For the curious, the Zorro default C++ compiler options do not override struct alignment.

Code
#include <zorro.h>

typedef struct FOO1{
	char a;
	double b;
} FOO1;
#pragma pack(push,1)
typedef struct FOO2{
	char a;
	double b;
} FOO2;
#pragma pack(pop)

DLLFUNC void main() {
	set(LOGFILE);
	FOO1 foo1={};
	FOO2 foo2={};
	char *pA=0,*pB=0;
	pA = (char*)&foo1.a;
	pB = (char*)&foo1.b;
	printf("\nA: %p, B: %p, diff: %d",pA,pB,pB-pA);
	pA = (char*)&foo2.a;
	pB = (char*)&foo2.b;
	printf("\nA: %p, B: %p, diff: %d",pA,pB,pB-pA);
	printf("\nDone!");
}

/* LOG OUTPUT:

A: 0000006041F0B280, B: 0000006041F0B288, diff: 8
A: 0000006041F0B270, B: 0000006041F0B271, diff: 1
Done!

*/
Posted By: AndrewAMD

Re: C++ scripts - 07/02/22 13:02

Miscellaneous C++ problems:

1) cancelTrade is missing the overload where TRADE* is an argument.

2) distribute() function is missing. (but we do have distribute0 and distribute1.)
Posted By: jcl

Re: C++ scripts - 07/04/22 13:02

Thanks, this will be fixed in the next beta. Please continue to test.
© 2024 lite-C Forums