Posted By: NorbertSz
zorro.h conflicts with std - how to make Zorro libraries in C++ - 02/10/23 07:32
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:
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:
This generates a lot of dummy errors:
This also compiles:
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.
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!
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!