Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Compiler warnings (bugs?) in zorro.h #487005
12/21/22 17:20
12/21/22 17:20
Joined: Dec 2022
Posts: 3
F
Ferris Offline OP
Guest
Ferris  Offline OP
Guest
F

Joined: Dec 2022
Posts: 3
Hi everyone,

in the process of working on Rust bindings for Zorro, I got 2 compiler warnings about unused expression results, both in zorro.h (version 2.50.2):
1. In the `loop` function, about the expression `CCC(p19, p20)` (where the line break is):
Code
inline char* loop(const char* p0 = 0, const char* p1 = 0, const char* p2 = 0, const char* p3 = 0, const char* p4 = 0, const char* p5 = 0, const char* p6 = 0, const char* p7 = 0, const char* p8 = 0, const char* p9 = 0, const char* p10 = 0, const char* p11 = 0, const char* p12 = 0, const char* p13 = 0, const char* p14 = 0, const char* p15 = 0, const char* p16 = 0, const char* p17 = 0, const char* p18 = 0, const char* p19 = 0,
	const char* p20 = 0, const char* p21 = 0, const char* p22 = 0, const char* p23 = 0, const char* p24 = 0, const char* p25 = 0, const char* p26 = 0, const char* p27 = 0, const char* p28 = 0, const char* p29 = 0, const char* p30 = 0, const char* p31 = 0, const char* p32 = 0, const char* p33 = 0, const char* p34 = 0, const char* p35 = 0, const char* p36 = 0, const char* p37 = 0, const char* p38 = 0, const char* p39 = 0)
{ return loop0(CCC(p0), CCC(p1), CCC(p2), CCC(p3), CCC(p4), CCC(p5), CCC(p6), CCC(p7), CCC(p8), CCC(p9), CCC(p10), CCC(p11), CCC(p12), CCC(p13), CCC(p14), CCC(p15), CCC(p16), CCC(p17), CCC(p18), CCC(p19,
		p20), CCC(p21), CCC(p22), CCC(p23), CCC(p24), CCC(p25), CCC(p26), CCC(p27), CCC(p28), CCC(p29), CCC(p30), CCC(p31), CCC(p32), CCC(p33), CCC(p34), CCC(p35), CCC(p36), CCC(p37), CCC(p38), CCC(p39));
}


CCC is defined as `#define CCC const_cast<char*>`.
So `CCC(p19, p20)` expands to `const_cast<char*>(p19, p20)`, but `(p19, p20)` evaluates to `p20` (comma-separated expressions will result in the value of the last expression: https://stackoverflow.com/a/52558).
So `p19` doesn't get used, which is why the compiler complains about an unused result.
Probably the intention was to write `CCC(p19), CCC(p20)` instead, right? Similarly to all the neighboring expressions.

2. In the `of` function, it's the same situation & compiler warning, again with `CCC(p19, p20)`.

3. The compiler didn't warn about this one (because it's not used within the headers, but intended to be used by user code). I noticed it by reading through the headers: In variables.h, there is this:
Code
#define TradeComboLeg	((g->tr->nContract&COMBOLEG))>>9)

The last parenthesis is unmatched, there are 2 opening but 3 closing parentheses. This would lead to a syntax error when using `TradeComboLeg` in user code. (Maybe there are similar such cases in #defines, this is just what I noticed for now.)

Correct me if I'm wrong regarding any of the above laugh

Re: Compiler warnings (bugs?) in zorro.h [Re: Ferris] #487011
12/22/22 15:47
12/22/22 15:47
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Thanks, that will be fixed in the next update. Until then, remove the second closing parenthesis, and replace the loop and of argument with CCC(p19),CCC(p20).


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1