Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (dr_panther, Quad), 903 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
zorro.h conflicts with std - how to make Zorro libraries in C++ #487205
02/10/23 07:32
02/10/23 07:32
Joined: Jan 2022
Posts: 58
N
NorbertSz Offline OP
Junior Member
NorbertSz  Offline OP
Junior Member
N

Joined: Jan 2022
Posts: 58
Hello,

I am trying to compile with C++.
I have my own libraries called "libA.h" and an other called "libB.h".
I include standard stuff in those libs header files like <map>, <fstream>, etc. and of course also <zorro.h>.
If I include them one after another, the compiler floods me a lot of strange, dummy errors.

I guess the reason is connected with this warning I found in Zorro Help a few grey hairs later:

Quote

Colliding definitions
Many lite-C variables and flags are pre-defined in variables.h and trading.h. If you're using a C++ library with a function, variable, or flag that has the same name, undefine the lite-C keyword with an #undef statement after including zorro.h and before including the headers of your library. Otherwise you'll get compiler errors.


My exact problem here is that <zorro.h> conflicts with the std libraries.

This compiles:
Code
#include <map>
#include <zorro.h>
DLLFUNC void run() {
	printf("hello world\n");
}

This generates a lot of dummy errors:
Code
#include <zorro.h>
#include <map>
DLLFUNC void run() {
	printf("hello world\n");
}

This also compiles:
Code
#include <map>
#include <zorro.h>
#include <map>
DLLFUNC void run() {
	printf("hello world\n");
}


If I would only have one script file for the whole strategy, it would be okay to put the <zorro.h> to the end of the includes, but if I have a larger codebase, it's not possible. When I am making my own Zorro library, that moment I don't know how will I reuse that code in another project in the future. So when I want to include <map> after <zorro.h> (include "libA.h" that includes <zorro.h>, then include "libB.h" that includes <map>) - the compiler fails. As I understand, to prevent the compiler error, Zorro Help suggest that I should browse through all of the <map> and it's std includes for searching the conflicting #defines, and #undef them before using that library. But in another project I will use another std library.

So it would be much practical to make <zorro.h> compatible with std. Or if it's not possible,
#undef all of the <zorro.h> definitions before including something else - for example in the beginning of the custom library's header file.
Code
#pragma once
#undef all of the Zorro definitions
#include <map>
#include <fstream>
#include <vector>
...
#include <zorro.h>

class Asd {
   public:
      Asd(var a);     // "var" is a keyword defined by zorro.h, so we absolutely need zorro.h in the header files also
      ...
}

It is possible? Maybe is there a zorro-undef.h somewhere (without include guard)?
If not, how should we do this: include at least two Zorro-related libraries that includes zorro.h and other standard dependencies?
...or am I in a completely wrong track?

Thank you very much!

Last edited by NorbertSz; 02/10/23 15:07.
Re: zorro.h conflicts with std - how to make Zorro libraries in C++ [Re: NorbertSz] #487219
02/11/23 16:45
02/11/23 16:45
Joined: Jan 2022
Posts: 58
N
NorbertSz Offline OP
Junior Member
NorbertSz  Offline OP
Junior Member
N

Joined: Jan 2022
Posts: 58
The only working and flexible-ish solution I made up is the following.

Because this works...
Code
#include <map>
#include <zorro.h>
#include <map>

... I made a header file called "common-library-loader.h", where I include ALL the necessary std libraries used across ALL of my libraries, then include <zorro.h>. Therefore it's kind of making a huge all-inclusive library, and the correct sequence is guaranteed for the first time - and after that it's not important. It's an ugly way, but working. However it would be much better if I shouldn't do this hacky way, so if you have any suggestions, I would glad to read that.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1