| [ Return to Bugs & Features | Roadmap 1.3 | SVN ⇄ GIT ]
STR #3060
Application: | FLTK Library |
Status: | 1 - Closed w/Resolution |
Priority: | 2 - Low, e.g. a documentation error or undocumented side-effect |
Scope: | 2 - Specific to an operating system |
Subsystem: | Build Files |
Summary: | Projects using FLTK and C++11 will not compile with some Windows compilers |
Version: | 1.3-current |
Created By: | mjsurette |
Assigned To: | AlbrechtS |
Fix Version: | None |
Update Notification: | |
Trouble Report Files:
Trouble Report Comments:
|
#1 | mjsurette 12:47 Mar 01, 2014 |
| Due to WIN32 not being defined by the compiler when the -std=c++11 flag is set, TDM-GCC does not define WIN32. There may be others as this is standards driven.
This results in not being able to use C++11 features in projects that use FLTK due to some tests for this being in the api headers, with compiler errors ensuing if this is attempted. | |
|
#2 | mjsurette 14:03 Mar 01, 2014 |
| Note to self: test BEFORE submitting, no matter how simple.
This is the working, and tested patch for this issue. | |
|
#3 | mjsurette 06:39 Mar 02, 2014 |
| My appologies, such a simple patch should not take 3 tries.
Tested with a clear head and a clean svn tree. | |
|
#4 | mjsurette 16:53 Mar 04, 2014 |
| Here's the new header file and patch that includes it in all header files that use the WIN32 define. | |
|
#5 | mjsurette 00:05 Mar 05, 2014 |
| Missed a #endif.
Tested and works. | |
|
#6 | AlbrechtS 05:25 Mar 05, 2014 |
| Is there a chance that fix_win32.H might be included in a C compilation? If so, the comments should be in C-style /* ... */, and maybe it should also be lowercase '.h' instead of '.H'.
Sorry, I don't have time to check right now, but wanted to post this thought so that it doesn't get lost. | |
|
#7 | mjsurette 16:27 Mar 05, 2014 |
| Fixed for inclusion in C headers. | |
|
#8 | AlbrechtS 03:49 Jul 14, 2015 |
| Michael, I believe this STR is obsolete for two reasons:
(1) It has always been the case that WIN32 /must/ be defined by the user to enable FLTK Windows support in their own projects. This is done, for instance, by fltk-config when defining CFLAGS etc., and the Windows IDE files explicitly define WIN32 as well.
(2) Isn't there another solution already in the FLTK CMake files? Although this other solution may not be optimal (or even not correct) I assume that it would solve whatever issue we have here. This is what I found:
setup.cmake:69:# fix no WIN32 defined issue setup.cmake:70:if(NOT WIN32) setup.cmake:71: if(_WIN32) setup.cmake:72: set(WIN32 _WIN32) setup.cmake:73: elseif(__WIN32__) setup.cmake:74: set(WIN32 __WIN32__) setup.cmake:75: endif(_WIN32) setup.cmake:76:endif(NOT WIN32)
Can we close this STR? | |
|
#9 | mjsurette 04:08 Jul 15, 2015 |
| TDM-GCC is the only compiler that I've come across that does not define WIN32 when the c++11 flag is used even though this is not standards compliant.
TDM-GCC does not come with MSYS or an equivalent, so if you use it, chances are very good you will be using CMake.
As you point out, this issue is handled in the CMake config files.
Given all this, I personally think it would be safe to close this STR without applying the patches. | |
|
#10 | AlbrechtS 04:11 Jul 17, 2015 |
| Thanks for your feedback.
FTR: MinGW g++ does not define WIN32 as well if used with -std=c++11, but does define WIN32 with -std=gnu++11. Maybe Here is a log of my own test program:
$ g++ -o symbols -std=c++11 symbols.cxx && ./symbols
WIN32 is NOT defined _WIN32 is defined as '1' __WIN32 is defined as '1' __WIN32__ is defined as '1' _WIN32_WINNT is NOT defined
$ g++ -o symbols -std=gnu++11 symbols.cxx && ./symbols
WIN32 is defined as '1' _WIN32 is defined as '1' __WIN32 is defined as '1' __WIN32__ is defined as '1' _WIN32_WINNT is NOT defined
Final note: users SHOULD define WIN32 in their own compiler commands (IDE projects, Makefiles, CMake files, etc.) if they build their own projects under Windows, as it is done when using fltk-config (output from MinGW):
$ ./fltk-config --cxxflags -I. -I./png -I./zlib -I./jpeg -mwindows -DWIN32 -DUSE_OPENGL32 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
Closing STR now. | |
[ Return to Bugs & Features ]
|
| |