We probably need to do something like (untested):#ifdef _WIN32
# if !(defined _WIN32_IE) || (_WIN32_IE < 0x0500)
# undef _WIN32_IE
# define _WIN32_IE 0x0500
# endif /* _WIN32_WINNT checks */
#endif /* _WIN32 */At the top of Fl_WinAPI_System_Driver.cxx as a workaround for this?
On Thursday, 20 April 2023 at 13:25:48 UTC+1 imacarthur wrote:
We probably need to do something like (untested):
#ifdef _WIN32
# if !(defined _WIN32_IE) || (_WIN32_IE < 0x0500)
# undef _WIN32_IE
# define _WIN32_IE 0x0500
# endif /* _WIN32_WINNT checks */
#endif /* _WIN32 */
At the top of Fl_WinAPI_System_Driver.cxx as a workaround for this?
FWIW, I tried this tweak, and it seems to work.
That said, I do wonder if the issue is more to do with the mingw32 headers than with fltk per se.I'm not convinced that enum definition should be guarded by the _WIN32_IE macro check at all...
(And I do not have the "real" MS headers here to compare against, either.)
OK, great that you found this. I agree that we could do this and have two notes:
(1) We probably don't need '#ifdef _WIN32' because this file is only compiled under Windows anyway (we also include <windows.h> and more).
(2) I checked that 'SHGFP_TYPE_CURRENT == 0', hence we could replace the constant (name) with 0 and add a comment which would have the same effect.
Ian, can you please try option (2) just to be sure?
That said, I do wonder if the issue is more to do with the mingw32 headers than with fltk per se.I'm not convinced that enum definition should be guarded by the _WIN32_IE macro check at all...It's presumably done because these constants/functions didn't exist in versions older than '0x0500' which is IIRC Win XP or something like that.
How old are your MinGW header files? Maybe they are too old to "know" about these features?
On Thursday, 20 April 2023 at 15:15:49 UTC+1 Albrecht Schlosser wrote:
How old are your MinGW header files? Maybe they are too old to "know" about these features?
So I looked - I have a couple of mingw32 versions on this machine, one has the mingw32 files versioned as 5.0.2, the newer one has 5.3.0.Both do define the necessary enum, but both have the conditional guard around the definition.
I installed current MinGW today and my header files are version 5.4.2 and include the guard '#if (_WIN32_IE >= 0x0500)' and the build works well out of the box.
This is only an observation on my new installation, it doesn't mean that we should not "fix" it though...
On Thu, 20 Apr 2023, 20:48 Albrecht Schlosser wrote:
I installed current MinGW today and my header files are version 5.4.2 and include the guard '#if (_WIN32_IE >= 0x0500)' and the build works well out of the box.
This is only an observation on my new installation, it doesn't mean that we should not "fix" it though...
That's interesting - though I don't think it's the guards that are really the problem, in fact I think they're probably correct.
Rather I think the problem is that the toolchain doesn't seem to actually to be setting them at all so...
FWIW, I think that mingw64 toolchain does seem to be setting them, though it's headers don't seem to have them anyway.
The msvc tools do set the macros, of course...
I think setting them (as in my example) might still be a valid solution...?
I propose to define _WIN32_IE (as in your example) right before '#include <shlobj.h>' to avoid other potential side effects. Please test attached diff if it works for you.
There's one issue with this patch though: it could happen that it would #undef _WIN32_IE if it's not defined. Is this acceptable or would it perhaps issue compiler warnings? I tested such a case with 'gcc -Wall -W -Wpedantic -Wextra' and didn't get warnings, but I don't know if the standard "allows" it and didn't test with MS compilers. We could make sure that this doesn't happen with another #if defined(_WIN32_IE) but if it's not necessary we could just use my patch as-is.
Ian, if you test the patch and it works, would it be OK if I committed it?
On Friday, 21 April 2023 at 15:05:03 UTC+1 Albrecht Schlosser wrote:
I propose to define _WIN32_IE (as in your example) right before '#include <shlobj.h>' to avoid other potential side effects. Please test attached diff if it works for you.
Tested in various configs; seems to be working fine, at least for me!
There's one issue with this patch though: it could happen that it would #undef _WIN32_IE if it's not defined. Is this acceptable or would it perhaps issue compiler warnings? I tested such a case with 'gcc -Wall -W -Wpedantic -Wextra' and didn't get warnings, but I don't know if the standard "allows" it and didn't test with MS compilers. We could make sure that this doesn't happen with another #if defined(_WIN32_IE) but if it's not necessary we could just use my patch as-is.
I do not know for sure - I have never (as far as I can recall, anyway!) ever seen a warning from #undef'ing a macro that was not actually defined, but TBH I have no idea what the standards say, or whether there may be some compiler that would complain.
Ian, if you test the patch and it works, would it be OK if I committed it?
I'm happy with the patch, so go ahead with the commit.If you are interested in a trivial "improvement" it might be to adjust the comment:
// notably header versions 5.3.0 and earlier, whereas 5.4.2 seems to define _WIN32_IE as needed.
Because I see it fail with mingw32 header version 5.0.2 also. But that's a minor observation so feel free to ignore!