[Gambas-devel] Porting Gambas to cygwin

Tobias Boege tobias at ...692...
Wed Apr 30 14:44:44 CEST 2014


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

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk





More information about the Devel mailing list