* Preprocessor defines in MS-Windows build
@ 2008-06-07 17:30 Eli Zaretskii
2008-06-07 19:04 ` Stefan Monnier
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Eli Zaretskii @ 2008-06-07 17:30 UTC (permalink / raw)
To: emacs-devel
Here's an example of a typical compilation command line on Windows:
gcc -I. -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0400 -D_X86_=1 -c -gstabs+ -g3 -mtune=pentium4 -O2 -Di386 -D_CRTAPI1=_cdecl -Demacs=1 -DWINDOWSNT -DDOS_NT -DHAVE_CONFIG_H -I../nt/inc -D_UCHAR_T -DHAVE_NTGUI=1 -DUSE_CRT_DLL=1 -o oo-spd/i386/dispnew.o dispnew.c
This uses a lot -f -DSOMETHING switches, and it looks like most of
these are not needed, and almost all the rest can be put on
src/s/ms-w32.h. Can someone help understanding the purpose of each
switch?
Below I summarize what I gleaned from grepping fo each symbol in the
Emacs sources and in the system headers:
WIN32_LEAN_AND_MEAN -- needed to produce a leaner executable
_WIN32_WINNT -- needed to prevent accidental use of features
unavailable on older Windows versions we still
support
_X86_ -- not needed, defined automatically by MinGW
headers
i386 -- not needed
_CRTAPI1 -- used only in sysdep.c, can be replaced by a
literal _cdecl
WINDOWSNT -- needed for W32-specific code in Emacs
DOS_NT -- needed for code that is specific to both DOS
and W32 ports
_UCHAR_T -- not needed
HAVE_NTGUI -- can be replaced with WINDOWSNT, since the W32
build doesn't use any other GUI
USE_CRT_DLL -- looks like it's unneeded, since we never use
anything but the CRTDLL.dll runtime
(I've omitted the -DHAVE_CONFIG_H and -Demacs, which are common to all
platforms.)
Does someone know anything that contradicts the above? If not, I
think we should remove those defines that are not needed anymore, and
put those which are needed in ms-w32.h.
Comments?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Preprocessor defines in MS-Windows build
2008-06-07 17:30 Preprocessor defines in MS-Windows build Eli Zaretskii
@ 2008-06-07 19:04 ` Stefan Monnier
2008-06-07 20:25 ` Eli Zaretskii
2008-06-07 21:57 ` Jason Rumney
2008-06-26 22:47 ` Juanma Barranquero
2 siblings, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2008-06-07 19:04 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
> Here's an example of a typical compilation command line on Windows:
> gcc -I. -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0400 -D_X86_=1 -c -gstabs+ -g3 -mtune=pentium4 -O2 -Di386 -D_CRTAPI1=_cdecl -Demacs=1 -DWINDOWSNT -DDOS_NT -DHAVE_CONFIG_H -I../nt/inc -D_UCHAR_T -DHAVE_NTGUI=1 -DUSE_CRT_DLL=1 -o oo-spd/i386/dispnew.o dispnew.c
> This uses a lot -f -DSOMETHING switches, and it looks like most of
Similar issues show on other platforms. I recently made minro changes
to remove on or the other of those defines and move it into
src/config.h instead.
> these are not needed, and almost all the rest can be put on
> src/s/ms-w32.h.
Ideally src/config.h, no (tho maybe it's more difficult)?
> Can someone help understanding the purpose of each switch?
> Below I summarize what I gleaned from grepping fo each symbol in the
> Emacs sources and in the system headers:
Look at admin/CPP-DEFINES as well (and update/improve it whenever
possible, of course).
> HAVE_NTGUI -- can be replaced with WINDOWSNT, since the W32
> build doesn't use any other GUI
Don't we support W32 builds without GUI?
> Does someone know anything that contradicts the above? If not, I
> think we should remove those defines that are not needed anymore, and
> put those which are needed in ms-w32.h.
Sounds fine to me,
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Preprocessor defines in MS-Windows build
2008-06-07 19:04 ` Stefan Monnier
@ 2008-06-07 20:25 ` Eli Zaretskii
2008-06-08 3:09 ` Stefan Monnier
0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2008-06-07 20:25 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: emacs-devel@gnu.org
> Date: Sat, 07 Jun 2008 15:04:21 -0400
>
> > these are not needed, and almost all the rest can be put on
> > src/s/ms-w32.h.
>
> Ideally src/config.h, no (tho maybe it's more difficult)?
You mean, nt/config.nt (that is copied into src/config.h), right?
Why is that better, btw?
> Look at admin/CPP-DEFINES as well (and update/improve it whenever
> possible, of course).
I already did. It doesn't say anything helpful about the defines I
listed, and doesn't have any additional ones.
> > HAVE_NTGUI -- can be replaced with WINDOWSNT, since the W32
> > build doesn't use any other GUI
>
> Don't we support W32 builds without GUI?
No, not AFAIK. The produced binary can be run with the -nw switch,
but it has GUI support built in.
> > Does someone know anything that contradicts the above? If not, I
> > think we should remove those defines that are not needed anymore, and
> > put those which are needed in ms-w32.h.
>
> Sounds fine to me,
Thanks for the feedback.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Preprocessor defines in MS-Windows build
2008-06-07 17:30 Preprocessor defines in MS-Windows build Eli Zaretskii
2008-06-07 19:04 ` Stefan Monnier
@ 2008-06-07 21:57 ` Jason Rumney
2008-06-07 23:53 ` Óscar Fuentes
2008-06-26 22:47 ` Juanma Barranquero
2 siblings, 1 reply; 11+ messages in thread
From: Jason Rumney @ 2008-06-07 21:57 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
Eli Zaretskii wrote:
> _X86_ -- not needed, defined automatically by MinGW
> headers
> i386 -- not needed
>
They may not be needed for a mingw build, but do the msvc headers also
define them?
> HAVE_NTGUI -- can be replaced with WINDOWSNT, since the W32
> build doesn't use any other GUI
>
This is there so that theoretically users can build a smaller text only
Emacs. I have never heard of anyone doing so in the last ten years, and
would not be surprised if such a build fails, especially since the
multi-tty and unicode merges, so it may not be important. Perhaps it
should be added to the list of variables appended to src/config.h by
configure.bat to make it easier to test the text-only build.
> USE_CRT_DLL -- looks like it's unneeded, since we never use
> anything but the CRTDLL.dll runtime
>
I think there was at least an experimental attempt many years ago to use
MSVCRT.dll with the msvc compiler, and if we are ever to get more recent
versions of msvc working again it will be necessary to keep this around.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Preprocessor defines in MS-Windows build
2008-06-07 21:57 ` Jason Rumney
@ 2008-06-07 23:53 ` Óscar Fuentes
2008-06-08 6:36 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Óscar Fuentes @ 2008-06-07 23:53 UTC (permalink / raw)
To: emacs-devel
Jason Rumney <jasonr@gnu.org> writes:
> Eli Zaretskii wrote:
>> _X86_ -- not needed, defined automatically by MinGW
>> headers
>> i386 -- not needed
>>
>
> They may not be needed for a mingw build, but do the msvc headers also
> define them?
I quick check for VC6 does not find i386. _X86_ is in WINDOWS.H
[snip]
>> USE_CRT_DLL -- looks like it's unneeded, since we never use
>> anything but the CRTDLL.dll runtime
>
> I think there was at least an experimental attempt many years ago to
> use MSVCRT.dll with the msvc compiler, and if we are ever to get more
> recent versions of msvc working again it will be necessary to keep
> this around.
CRTDLL.dll (?) is not on the list of loaded dll's for an Emacs
process. MSVCRT.dll is.
--
Oscar
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Preprocessor defines in MS-Windows build
2008-06-07 20:25 ` Eli Zaretskii
@ 2008-06-08 3:09 ` Stefan Monnier
0 siblings, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2008-06-08 3:09 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
>> Ideally src/config.h, no (tho maybe it's more difficult)?
> You mean, nt/config.nt (that is copied into src/config.h), right?
I guess so.
> Why is that better, btw?
I just assume that the closer it is to the way other builds work
(i.e. autoconf in this case) the better.
>> > HAVE_NTGUI -- can be replaced with WINDOWSNT, since the W32
>> > build doesn't use any other GUI
>> Don't we support W32 builds without GUI?
> No, not AFAIK. The produced binary can be run with the -nw switch,
> but it has GUI support built in.
I see. But keeping a separate HAVE_NTGUI still makes sense in case we
want to allow non-GUI builds (or in case we ever want to provide an X11
version of the W32 build). It's not important to keep the distinction,
but I don't see much benefit in getting rid of rid.
>> > Does someone know anything that contradicts the above? If not, I
>> > think we should remove those defines that are not needed anymore, and
>> > put those which are needed in ms-w32.h.
>> Sounds fine to me,
> Thanks for the feedback.
My pleasure,
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Preprocessor defines in MS-Windows build
2008-06-07 23:53 ` Óscar Fuentes
@ 2008-06-08 6:36 ` Eli Zaretskii
2008-06-09 1:55 ` David Robinow
0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2008-06-08 6:36 UTC (permalink / raw)
To: Óscar Fuentes; +Cc: emacs-devel
> From: =?iso-8859-1?Q?=D3scar_Fuentes?= <ofv@wanadoo.es>
> Date: Sun, 08 Jun 2008 01:53:29 +0200
>
> Jason Rumney <jasonr@gnu.org> writes:
>
> > Eli Zaretskii wrote:
> >> _X86_ -- not needed, defined automatically by MinGW
> >> headers
> >> i386 -- not needed
> >>
> >
> > They may not be needed for a mingw build, but do the msvc headers also
> > define them?
>
> I quick check for VC6 does not find i386. _X86_ is in WINDOWS.H
Sorry, I don't see any significance of this for MSVC. Jason, are you
saying that compiling _any_ program with cl, the MS compiler,
_requires_ the -Di386 and -D_X86_ switches? I don't think so. If
not, then why do we need to tell cl it is compiling an x86 program? it
should know that by default.
Can someone with MSVC please see if removing these two switches causes
any trouble?
> >> USE_CRT_DLL -- looks like it's unneeded, since we never use
> >> anything but the CRTDLL.dll runtime
> >
> > I think there was at least an experimental attempt many years ago to
> > use MSVCRT.dll with the msvc compiler, and if we are ever to get more
> > recent versions of msvc working again it will be necessary to keep
> > this around.
>
> CRTDLL.dll (?) is not on the list of loaded dll's for an Emacs
> process. MSVCRT.dll is.
Yes, so what do we need USE_CRT_DLL for, again?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Preprocessor defines in MS-Windows build
2008-06-08 6:36 ` Eli Zaretskii
@ 2008-06-09 1:55 ` David Robinow
2008-06-09 8:42 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: David Robinow @ 2008-06-09 1:55 UTC (permalink / raw)
To: emacs-devel; +Cc: eliz
On Sun, Jun 8, 2008 at 2:36 AM, Eli Zaretskii <> wrote:
>> From: =?iso-8859-1?Q?=D3scar_Fuentes?= <ofv@wanadoo.es>
>> Date: Sun, 08 Jun 2008 01:53:29 +0200
>> I quick check for VC6 does not find i386. _X86_ is in WINDOWS.H
>
> Sorry, I don't see any significance of this for MSVC. Jason, are you
> saying that compiling _any_ program with cl, the MS compiler,
> _requires_ the -Di386 and -D_X86_ switches? I don't think so. If
> not, then why do we need to tell cl it is compiling an x86 program? it
> should know that by default.
>
> Can someone with MSVC please see if removing these two switches causes
> any trouble?
Removing -Di386 does not seem to cause a problem (MSVC 2003). That
is, I've been running the result for 5 minutes.
I haven't tried compiling without _X86_ yet.
i386 is not present in any of the standard include files. _X86_
appears in several places.
_X86_ is not present by default.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Preprocessor defines in MS-Windows build
2008-06-09 1:55 ` David Robinow
@ 2008-06-09 8:42 ` Eli Zaretskii
0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2008-06-09 8:42 UTC (permalink / raw)
To: David Robinow; +Cc: emacs-devel
> Date: Sun, 8 Jun 2008 21:55:44 -0400
> From: "David Robinow" <drobinow@gmail.com>
> Cc: eliz@gnu.org
>
> > Can someone with MSVC please see if removing these two switches causes
> > any trouble?
> Removing -Di386 does not seem to cause a problem (MSVC 2003). That
> is, I've been running the result for 5 minutes.
Thanks for testing.
> I haven't tried compiling without _X86_ yet.
> i386 is not present in any of the standard include files. _X86_
> appears in several places.
>
> _X86_ is not present by default.
I think the compiler defines it by default, because it knows it was
built for x86 architecture. But I cannot be sure, since the MSDN docs
don't mention it, they document _M_IX86 instead... Wait, I think I
found it: in Windows.h there's this snippet:
#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_IX86)
#define _X86_
#endif
So I think _X86_ is a legacy macro that was replaced with _M_IX86
(which has a value that indicates the architecture for which the
program is built, like the GCC's -mtune switch), and the above takes
care of defining it when the compiler builds a native x86 program.
Again, thanks for helping us understand the meaning and effect of
these macros.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Preprocessor defines in MS-Windows build
2008-06-07 17:30 Preprocessor defines in MS-Windows build Eli Zaretskii
2008-06-07 19:04 ` Stefan Monnier
2008-06-07 21:57 ` Jason Rumney
@ 2008-06-26 22:47 ` Juanma Barranquero
2008-06-27 8:59 ` Eli Zaretskii
2 siblings, 1 reply; 11+ messages in thread
From: Juanma Barranquero @ 2008-06-26 22:47 UTC (permalink / raw)
To: emacs-devel Mailinglist
On Sat, Jun 7, 2008 at 19:30, Eli Zaretskii <eliz@gnu.org> wrote:
> Here's an example of a typical compilation command line on Windows:
>
> gcc -I. -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0400 -D_X86_=1 -c -gstabs+ -g3 -mtune=pentium4 -O2 -Di386 -D_CRTAPI1=_cdecl -Demacs=1 -DWINDOWSNT -DDOS_NT -DHAVE_CONFIG_H -I../nt/inc -D_UCHAR_T -DHAVE_NTGUI=1 -DUSE_CRT_DLL=1 -o oo-spd/i386/dispnew.o dispnew.c
I've committed changes removing (or moving to nt/config.nt) everything
that seems safe to (re)move.
> WIN32_LEAN_AND_MEAN -- needed to produce a leaner executable
> _WIN32_WINNT -- needed to prevent accidental use of features
Moved to nt/config.nt.
> _X86_ -- not needed, defined automatically by MinGW
> headers
> i386 -- not needed
> _CRTAPI1 -- used only in sysdep.c, can be replaced by a
> literal _cdecl
Removed.
> WINDOWSNT -- needed for W32-specific code in Emacs
> DOS_NT -- needed for code that is specific to both DOS
> and W32 ports
Removed, they are defined in src/s/ms-w32.h if not already defined.
> _UCHAR_T -- not needed
Removed.
> HAVE_NTGUI -- can be replaced with WINDOWSNT, since the W32
> build doesn't use any other GUI
Not removed. Stefan felt that it could be useful in case we ever do a
non-GUI Windows build.
> USE_CRT_DLL -- looks like it's unneeded, since we never use
> anything but the CRTDLL.dll runtime
Not removed. According to Jason, it could be useful when building with
newer MSVC compilers.
I've tested the changes with MinGW. They should work also with MSVC;
if not, please holler.
Juanma
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Preprocessor defines in MS-Windows build
2008-06-26 22:47 ` Juanma Barranquero
@ 2008-06-27 8:59 ` Eli Zaretskii
0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2008-06-27 8:59 UTC (permalink / raw)
To: Juanma Barranquero; +Cc: emacs-devel
> Date: Fri, 27 Jun 2008 00:47:37 +0200
> From: "Juanma Barranquero" <lekktu@gmail.com>
>
> On Sat, Jun 7, 2008 at 19:30, Eli Zaretskii <eliz@gnu.org> wrote:
>
> > Here's an example of a typical compilation command line on Windows:
> >
> > gcc -I. -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0400 -D_X86_=1 -c -gstabs+ -g3 -mtune=pentium4 -O2 -Di386 -D_CRTAPI1=_cdecl -Demacs=1 -DWINDOWSNT -DDOS_NT -DHAVE_CONFIG_H -I../nt/inc -D_UCHAR_T -DHAVE_NTGUI=1 -DUSE_CRT_DLL=1 -o oo-spd/i386/dispnew.o dispnew.c
>
> I've committed changes removing (or moving to nt/config.nt) everything
> that seems safe to (re)move.
Thanks!
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-06-27 8:59 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-07 17:30 Preprocessor defines in MS-Windows build Eli Zaretskii
2008-06-07 19:04 ` Stefan Monnier
2008-06-07 20:25 ` Eli Zaretskii
2008-06-08 3:09 ` Stefan Monnier
2008-06-07 21:57 ` Jason Rumney
2008-06-07 23:53 ` Óscar Fuentes
2008-06-08 6:36 ` Eli Zaretskii
2008-06-09 1:55 ` David Robinow
2008-06-09 8:42 ` Eli Zaretskii
2008-06-26 22:47 ` Juanma Barranquero
2008-06-27 8:59 ` Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.