Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (M_D, AndrewAMD, Quad, Ayumi), 806 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Changing char* to const char* in SDK? #446106
10/05/14 15:56
10/05/14 15:56
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline OP
Expert
MasterQ32  Offline OP
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
Hey!

I'm currently working with the Engine SDK and i'm wondering why functions like bmap_create need to have a char* parameter?
It's really annoying as i also need to cast string literals to char*:
Code:
BMAP *bmp = bmap_create((char*)"filename.png");



Much better would be the "correct" version with const char* instead of char*.

I don't think those methods have any sideffects on the parameter, right? Would be nice if this could be expressed in the method call itself.

Regards
Felix


Visit my site: www.masterq32.de
Re: Changing char* to const char* in SDK? [Re: MasterQ32] #446137
10/06/14 13:42
10/06/14 13:42
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
it is annoying to type cast so much with gs in c++
that is why I use macros and re written functions instead... wich is also a bummer


Compulsive compiler
Re: Changing char* to const char* in SDK? [Re: Wjbender] #446141
10/06/14 16:15
10/06/14 16:15
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
If you need type casts depends on your compiler version and project settings. But you can redefine the functions with const char* in afuncs.h - they have been defined with char* for using the same header both in C++ and lite-C.

Re: Changing char* to const char* in SDK? [Re: jcl] #446147
10/06/14 16:52
10/06/14 16:52
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline OP
Expert
MasterQ32  Offline OP
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
Maybe it could be done with a specific define for constness:
Code:
// acknex.h
#define ENGINE_CONST


Code:
// adll.h
#define ENGINE_CONST const


Code:
// afuncs.h
EXT BMAP* F(bmap_create)(ENGINE_CONST char* filename);



I adjusted the prototypes in my current afuncs.h but i'm don't think this should be done by any user...


Visit my site: www.masterq32.de
Re: Changing char* to const char* in SDK? [Re: MasterQ32] #446148
10/06/14 16:54
10/06/14 16:54
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Normally not, but you have my special permission. wink


Moderated by  old_bill, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1