Re: Predefine _M_IX86 in gcc

Cosmin Truta <[email protected]>
Newsgroups gmane.comp.gnu.mingw.patches
Message-ID <[email protected]>
On Tue, 17 Dec 2002, Danny Smith wrote:

> > 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.
>
> Those defines are done for you if you include windows.h.
> _M_IX86 is defined in winnt.h
> CALLBACK is defined in windef.h

Right, but this is not the point.

I merely showed you an example where the pre-definition of _M_IX86 might
be desirable. The example is meant to make <GL/glut.h> work without
including <windows.h>.

The purpose of GLUT is to achieve platform independence, and this includes
the avoidance of <win*.h>.

I see that one may include <winnt.h>, or <windows.h> for that matter,
but AFAIK the purpose of MinGW is to assure a smooth transition of the
programs that compile with MSC-Win and/or gcc-othersys.

In the _very_particular_ example I gave you, the author of GLUT wanted to
provide CALLBACK and other things defined by <windows.h> and required by
<GL/gl.h> and <GL/glu.h>, *but* without including <windows.h>. The purpose
was to avoid the useless namespace pollution, since <windows.h> was not
necessary for any other reason.


Now let's go back to the general reason:


As pre-defined by both MSC and Borland C, _M_IX86 has a purpose similar
to __i386__, __i686__ etc, and the user should not be required to do
an extra task (such as including <windows.h>, or defining the symbol in
the makefile) in order to get it right with GCC.
Actually, _M_IX86 should be the Win32-portable equivalent of __i386__
and its friends.

Here is a little more _M_IX86 advocacy that I will throw in:

  #ifdef _M_IX86
is better than
  #if defined(__i386__) || defined(__i486__) || defined...  // for GCC
or even
  #if defined(__i386__) || ... || defined(_M_IX86)  // for GCC and others
while
  #if _M_IX86==500
is still as good as
  #ifdef __i586__


I've just looked into the mingw specs, and I saw in the long line
  "... march=i486:-D__i486 -D__i486__ ..."
which can go into
  "... march=i486:-D__i486 -D__i486__ -D_M_IX86=400 ..."

However, if you do not wish to predefine _M_IX86 for some reason,
I understand.

Cosmin



-------------------------------------------------------
This SF.NET email is sponsored by: Order your Holiday Geek Presents Now!
Green Lasers, Hip Geek T-Shirts, Remote Control Tanks, Caffeinated Soap,
MP3 Players,  XBox Games,  Flying Saucers,  WebCams,  Smart Putty.
T H I N K G E E K . C O M       http://www.thinkgeek.com/sf/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.