[Gambas-devel] Porting Gambas to cygwin

Benoît Minisini gambas at ...1...
Sun May 4 00:03:56 CEST 2014


Le 30/04/2014 14:44, Tobias Boege a écrit :
> On Wed, 30 Apr 2014, Nigel Gerrard wrote:
>> I have now resolved the issue with the following when compiling gb.sdl
>> in cygwin:
>>
>>> In file included from /usr/include/sys/types.h:20:0, > from
>> ../gambas.h:30, > from Cconst.cpp:25: > ../gambas.h:1213:22: error:
>> expected initializer before '.' token > #define strcasecmp GB.StrCaseCmp >
>> ^ > ../gambas.h:1214:23: error: expected initializer before '.' token >
>> #define strncasecmp GB.StrNCaseCmp > ^ It comes down to the order of the
>> header definitions e.g. where gambas.h is declared before any of the SDL
>> headers that contain STD_stdinc.h (and thus <strings.h>). In this case my
>> assumption is that the prepocessor incorporates all the includes and then
>> redefines strcasecmp etc. including the definitions picked up from the
>> standard header. The question then is why does this cause a problem under
>> cygwin and not Linux.
>>
>
> I think what happens is the following:
>
> gambas.h #defines "strncasecmp" as something belonging to the GB structure
> (maybe to workaround a bug or something).
>
> As it ought to be, on Linux, the gambas.h header, being an "application"
> header, is included as late as possible during compilation so that precisely
> the uses of strncasecmp() in application code can be replaced with the
> wanted function in the GB structure.
>
> For some reason - I think -, the gambas.h header is read on cygwin _before_
> <strings.h> where strncasecmp is declared. Obviously, if the macro (because
> since the point gambas.h is read, it is a macro) strncasecmp is expanded to
> GB.StrNCaseCmp in the place where normally a function is declared, that will
> make the compiler complain.
>
> If that's the case, you have to either figure out why the inclusion order is
> this way and correct it (if possible) or simply remove the #define from
> gambas.h since, hey, the C library's strncasecmp() can't be _that_ bad :-)
>
> Regards,
> Tobi
>

The C library's strcasecmp() and strncasecmp() are _that_ bad. Because 
their behaviour depends on localization. In Turkish, "i" and "I" are not 
the same latter, and we need case insensitive string comparison 
independent of the localization in all languages, not in all language 
except Turkish.

Otherwise, if what you say is right, <strings.h> must be explicitely 
included at the beginning of <gambas.h> to fix the problem.

Regards,

-- 
Benoît Minisini




More information about the Devel mailing list