Predefine _M_IX86 in gcc
Cosmin Truta <[email protected]>
| Newsgroups | gmane.comp.gnu.mingw.patches |
|---|---|
| Message-ID | <[email protected]> |
Hi, I needed to use OpenGL/glut under MinGW. I grabbed glut-3.7.6, but I needed to do some fixing, so that CALLBACK is defined properly (below). This is a fragment of glut.h. # if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || \ defined(_M_PPC)) && !defined(MIDL_PASS) || defined(__LCC__) # define CALLBACK __stdcall # else # define CALLBACK # endif Adding "defined(__GCC__)" was a quick and effective fix for me. However, I think that _M_IX86 should be predefined when compiling a Win32/Intel program, regardless of the compiler used. I don't think it is only a MSC thing; for instance, Borland C defines it, too. I could have written to the glut maintainer to add "defined(__GCC__)" after __LCC__ (well, I wrote him about another issue), but I think it is gcc's job to predefine _M_IX86 instead. The specification is here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_PREDIR_Predefined_Macros.asp I believe it is easy to do this in the *cpp_cpucommon section in the gcc specs, but even a simple default "-D_M_IX86=300" should be more helpful than nothing. ** BTW: I also think it would be a good idea to supply MinGW with glut.h, since libglut32.a is already there. This is especially because the original glut.h required mingw-specific tweaking such as: /* MinGW-gcc requires GLUT_DISABLE_ATEXIT_HACK */ #ifdef __GNUC__ #define GLUT_DISABLE_ATEXIT_HACK #endif I don't know why this is necessary, perhaps it's because libglut32.a that you supply does not export symbols such as __glutCreateMenuWithExit, __glutCreateWindowWithExit, __glutCreateMenuWithExit Beware: the code above is a quick fix of mine, so please disregard it. I have no idea if this breaks on Cygwin. I am showing it only to prove that setting up glut under mingw is not at all a clean task right now. Anyway, the point is, it would be great (for me, at least) if glut.h would be supplied with mingw. I can write a request on MinGW-users if necessary. ** Best regards, Cosmin PS: Please cc: to "cosmin-at-cs...", as I am not subscribed to the list. ------------------------------------------------------- This sf.net email is sponsored by: With Great Power, Comes Great Responsibility Learn to use your power at OSDN's High Performance Computing Channel http://hpc.devchannel.org/