New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include win32defines.h before win32.h to fix build errors #570
Conversation
LGTM, and should fix @zhekov issue as he described. Maybe also define |
Under which conditions are build errors happening? I'm not seeing those. |
@kugel- I don't see errors neither but warnings. @zhekov mentioned build errors in #567. And closely reading the warning message, I got the include path of non-Geany headers:
@b4n, @zhekov: I'm not sure about defining _WIN32_WINNT as well. I don't know the exact difference between both and so I'm somewhat girlish minutes before 1.25. |
My _mingw.h has 224: #ifndef _WIN32_WINNT But no sign of WINVER anywhere. Anyway it suggest we should define this stuff before the system headers (which seem to have an #ifndef guard before redefining) |
http://blogs.msdn.com/b/oldnewthing/archive/2007/04/11/2079137.aspx describes both a bit. |
Which is what we do now with this change. |
Adding
But arguably the same header inclusion move should happen in all including files. |
I mean before windows.h and friends, what we do already without this |
Hold that, it's the same with
|
We have a # include "win32defines.h" in spawn? Please remove it, or move it before any other includes. Spawn requires neither WINVER nor WIN32_LEAN_AND_MEAN, and "win32defines.h" certainly can't be included based on glib.h-s G_OS_WIN32, because the glib.h headers include tons of stuff, and WINVER will be 100% surely to be defined at that point. |
@zhekov already fixed with the last commits: the include of win32defines.h is moved at the top. |
662544f
to
e5471fb
Compare
@zhekov before |
On 12.7.2015 г. 17:58, Colomban Wendling wrote:
Well, MinGW checks _WIN32_WINNT for SHGetFolderPathAndSubDir, but (To whoever might be interested, the MS SDK 7.0A checks NTDDI_VERSION E-gards: Jimmy |
Include win32defines.h before win32.h to fix build errors
Hold on. Most sources do not include "win32defines", but they include at least some standard headers under Windows, which means that WINVER etc. will be defined, and will receive their automatic values. spawn.c including windows.h is no different from build.c including stdlib.h - WINVER etc. will be defined in both cases. Thus being the case, there are 2 proper solutions:
The current approach, "include win32defines because something seems related to Windows", does not make much sense. |
My problem with 1 is that we have 3 build systems, so this means 3 versions of the same defines to keep in sync. Also, they seemed somewhat like code stuff to me. 2 why not, that's what I would have done but @codebrainz wanted to have them all the same when we included windows.h, and it seemed reasonable to me -- but I have really no clue about Windows details, I'm mostly happy when it works. So I really don't mind. But is it a problem how it's done now? I mean, would it create any issue, or is it just a bit crazy/unnecessary but without too much incidence? BTW, IIUC the main goal of having win32defines everywhere windows.h is included was to define the LEAN stuff so windows.h brings less unnecessary stuff (but I might be wrong). |
@zhekov BTW I was about to upload the 1.25 tarballs so if it'd be a real problem I'd like to know like now :) |
No, it will not be a problem AFAICT. Go on! I'll create a PR after the release, because:
|
My actually suggestion was below (pasted from closed PR #539), for the record :) Begin pasted text... I mean like this, in a geanywin32.h or win32private.h file or something: #pragma once
# ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# define VC_EXTRALEAN
# define WINVER 0x0501
# define _WIN32_IE 0x0500
# include <windows.h>
# include <commdlg.h>
# include <shellapi.h>
# include <shellobj.h>
# include <winsock2.h>
# include <gdk/gdkwin32.h>
// ...
# endif It would remove several lines from each file that uses Win32 API and make it more robust against forgetting to include the win32defines stuff or accidentally including it after windows.h where it does nothing. Kind of similar idea as gtk/gtk.h in a way. |
I see. Should have noticed #539 and discussed it at the time, but I missed it... The code suggested by you would have been more logical than what we ended up with. It's problems (as of me) are:
I plan to create a PR about win32defines.h, and to first explain in detail about WINVER and _WIN32_WINNT, when they should be defined etc. There are a lot of misconceptions, and Geany is written mostly by *nix programmers... |
If I understood correctly it
My thought was any win32-specific headers, especially those of the official Win32 API (as opposed to GLib/GTK+ stuff). It causes some extra unnecessary inclusions, but I doubt it's a big deal, and IMO "include what you use" is more important for our own headers than external libraries'. |
So true, at least for me. The current solution was a) because we don't know what we do on Windows |
Well, defining WIN32_LEAN_AND_MEAN + VC_EXTRALEAN, while at the same time including some of the headers excluded by them, is a bit strange. Shouldn't we avoid trying to guess precisely what the Win32 developers will/may need, and let them specify it? |
Created PR #573 with a long explanation about this Win~1 stuff, as planned. |
This should fix the problems mentioned in #567.
However, I don't get completely why win32.h includes _mingw.h or any other non-Geany headers.