This is the first Visual Studio release that officially supports C++11 (and later standards, too), and that defines the "__cplusplus" macro accordingly. Previous versions set this macro to an archaic version number, even if they provided more or less complete C++11 support, and the /std=c++11 option was used.
So, finally, DCMTK can be compiled with C++11 and STL support on Windows, without any hack (e.g. disabling the compiler checks by a patch).
The only things you need:
- configure DCMTK with -DDCMTK_CXX11_FLAGS:STRING=/Zc:__cplusplus
- add /Zc:__cplusplus to the CMAKE_CXX_FLAGS variable of your project
It would be nice if DCMTK could do the first automatically, or if it would not overwrite the flags with VS and C++11.
I wanted to provide a patch, but I'm not sure if this preview release can be distinguished from the previous previews reliably.
Maybe someone knows, how. Or anyway, maybe my findings will be useful for someone.
C++11 support with Visual Studio 15.7 Preview 3
Moderator: Moderator Team
-
- OFFIS DICOM Team
- Posts: 318
- Joined: Mon, 2014-03-03, 09:51
- Location: Oldenburg, Germany
Re: C++11 support with Visual Studio 15.7 Preview 3
What version of DCMTK are you using? We have some "per-feature" tests since DCMTK 3.6.2. I would be suprised if Visual Studio now implements std::error_code correctly, but this is also handled independently from the C++11 flag since version 3.6.2.
Re: C++11 support with Visual Studio 15.7 Preview 3
3.6.3
It builds fine, although I did not run its tests. Compiler checks are done at configuration and build time, those do pass.
It builds fine, although I did not run its tests. Compiler checks are done at configuration and build time, those do pass.
Re: C++11 support with Visual Studio 15.7 Preview 3
I ran the tests.
In release mode all the tests pass.
On debug mode one test crashes because of an assertion failure inside the STL implementation of VS:
This test:
ofstd_OFVector
Screenshot of the error:
https://ibb.co/ijMWBc
At this line:
https://github.com/DCMTK/dcmtk/blob/DCM ... vec.cc#L51
It looks like a bug in the VS library.
In release mode all the tests pass.
On debug mode one test crashes because of an assertion failure inside the STL implementation of VS:
This test:
ofstd_OFVector
Screenshot of the error:
https://ibb.co/ijMWBc
At this line:
https://github.com/DCMTK/dcmtk/blob/DCM ... vec.cc#L51
It looks like a bug in the VS library.
Re: C++11 support with Visual Studio 15.7 Preview 3
In debug mode this option has to be added to the C++ flags:
The default value is 2 for debug builds, causing a crash.
Unfortunately, this cannot be added to CMAKE_CXX_FLAGS_DEBUG, because it gets overwritten when building static libs, but it can be added to DCMTK_CXX11_FLAGS. One must be careful not to set this for release builds, though.
Code: Select all
/D_ITERATOR_DEBUG_LEVEL=1
Unfortunately, this cannot be added to CMAKE_CXX_FLAGS_DEBUG, because it gets overwritten when building static libs, but it can be added to DCMTK_CXX11_FLAGS. One must be careful not to set this for release builds, though.
-
- OFFIS DICOM Team
- Posts: 318
- Joined: Mon, 2014-03-03, 09:51
- Location: Oldenburg, Germany
Re: C++11 support with Visual Studio 15.7 Preview 3
Interesting. It seems they really made progress. I have just added a feature to our issue tracker: https://support.dcmtk.org/redmine/issues/824
Who is online
Users browsing this forum: No registered users and 1 guest