Announcement: Be excellent to each other.


Caravel Forum : Caravel Boards : Development : Brace-enclosed initializers.
New Topic New Poll Post Reply
Poster Message
halyavin
Level: Delver
Rank Points: 52
Registered: 02-20-2006
IP: Logged
icon Brace-enclosed initializers. (0)  
I am trying to compile drod using MinGW (gcc for windows platform). But I have to remove all brackets around symbols in unicode string constants, because gcc in MinGW doesn't support them (see also). Are this brackets absolutely necessary?

[Last edited by halyavin at 01-15-2008 09:48 AM]
01-15-2008 at 09:48 AM
View Profile Send Private Message to User Show all user's posts ICQ Status Quote Reply
JDAdams
Level: Delver
Rank Points: 33
Registered: 01-04-2008
IP: Logged
icon Re: Brace-enclosed initializers. (0)  
If you look in the thread just below this one you will see a guide to compiling in Dev-Cpp which notes the bracket issue. Suffice to say that yes, you need to remove the internal ones, e.g. { {E},{x},{a},{m},{p},{l},{e},{0} } becomes { E,x,a,m,p,l,e,0 }
01-15-2008 at 12:48 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
trick
Level: Legendary Smitemaster
Rank Points: 2578
Registered: 04-12-2003
IP: Logged
icon Re: Brace-enclosed initializers. (+2)  
You shouldn't remove those brackets, in stead you should replace {x} with We(x) for array initializers and W_t(x) otherwise. Some of these had been overlooked before, but I went through the code and fixed all of them some time ago (for a mingw port, actually). I don't think that's publicly available yet though.

WCHAR array[] = { {'f'},{'u'},{'n'},{0} };  →  WCHAR array[] = { We('f'),We('u'),We('n'),We(0) };
array[0] = {'r'};                           →  array[0] = W_t('r');
But anyway, yes, they are unfortunately a necessary evil. Some compilers abort if the brackets are there, other compilers abort if they're not there. gcc does both, depending on version/platform. If there was a portable way of specifying 16-bit wchar strings directly we wouldn't have to mess with all that stuff, but there isn't, so. (I'm aware of gcc's -fshort-wchar option, but that changes the ABI, so we can't use it.)


[Last edited by trick at 01-15-2008 03:57 PM]
01-15-2008 at 03:54 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
halyavin
Level: Delver
Rank Points: 52
Registered: 02-20-2006
IP: Logged

File: BracketsRemover.jar (5.8 KB)
Downloaded 6 times.
License: Public Domain
icon Re: Brace-enclosed initializers. (+3)  
I write a Java program to transform all unicode string definitions to We() form. If you copy it to directory with DROD's source, you just need write "java -jar BracketsRemover.jar . h cpp" in command line. Where "." is directory with sources, and "h cpp" is allowed file extensions. This program misses a couple of cases where an array of unicode string defined. These cases should be fixed manually :(.
PS Sources are embedded in .jar.
PSPS You need at least Java 1.5 to run the program.


[Last edited by halyavin at 01-17-2008 04:51 PM]
01-17-2008 at 04:50 PM
View Profile Send Private Message to User Show all user's posts ICQ Status Quote Reply
New Topic New Poll Post Reply
Caravel Forum : Caravel Boards : Development : Brace-enclosed initializers.
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.