cxong / cdogs-sdl

Classic overhead run-and-gun game
https://cxong.github.io/cdogs-sdl/
GNU General Public License v2.0
891 stars 114 forks source link

Error while compilling #124

Closed bugamn closed 11 years ago

bugamn commented 11 years ago

While trying to compile on Ubuntu 12.04 64bits I get the following error:

In file included from /home/daniel/Programs/cdogs-sdl/src/cdogs/input.h:56:0,
                 from /home/daniel/Programs/cdogs-sdl/src/cdogs/gamedata.h:53,
                 from /home/daniel/Programs/cdogs-sdl/src/cdogs/actors.h:52,
                 from /home/daniel/Programs/cdogs-sdl/src/cdogs/actors.c:49:
/home/daniel/Programs/cdogs-sdl/src/cdogs/sys_specifics.h:74:13: error: conflicting types for ‘ssize_t’
/usr/include/x86_64-linux-gnu/sys/types.h:110:19: note: previous declaration of ‘ssize_t’ was here
make[2]: *** [cdogs/CMakeFiles/cdogs.dir/actors.c.o] Error 1
make[1]: *** [cdogs/CMakeFiles/cdogs.dir/all] Error 2
make: *** [all] Error 2

The offending line corresponds to this:

#if !defined(ssize_t) && !defined(__MACTYPES__)
typedef int ssize_t;
#endif

But since ssize_t is a typedef and not a macro (created by #define), the defined() function won't work. I have wrote the following program as an example:

#include <stdio.h>

/*typedef int ssize_t;*/

int main(int argc, const char *argv[])
{
#if defined(ssize_t)
    printf("Hello\n");
#endif
    return 0;
}

If I uncomment the typedef, the program won't compile, because ssize_t is defined in stdio. It won't print "Hello\n", however, because defined() won't detect the typedef.

In sys/types.h, the typedef is declared as follows:

#ifndef __ssize_t_defined
typedef __ssize_t ssize_t;
# define __ssize_t_defined
#endif

I tried to use defined(__size_t_defined) in place of defined(ssize_t) and it compiled.

cxong commented 11 years ago

I've removed the typedef completely since ssize_t is no longer being used at all in code; thanks for reporting