[vtk-developers] Introducing (optional) C++11 features in VTK

Marcus D. Hanwell marcus.hanwell at kitware.com
Fri Aug 22 13:25:54 EDT 2014


On Fri, Aug 22, 2014 at 1:15 PM, Sean McBride <sean at rogue-research.com> wrote:
> Marcus,
>
> First, thanks for working on this!
>
> I realize you are just testing things out, but some comments nonetheless:
>
>
> On Fri, 22 Aug 2014 11:57:56 -0400, Marcus D. Hanwell said:
>
>>So my first pass at this, keeping the bar relatively low for now,
>>
>>http://review.source.kitware.com/#/t/4550/
>>
>>I have tested this both as default, and forcing to ANSI C++, on GCC
>>4.9.1. It would be pretty simple to extend this for Clang (I would
>>rather do it in a follow up commit).
>
> I think the term "ANSI C++" is horribly ambiguous, and shouldn't be used (ex: VTK_FORCE_ANSI_CXX).  Honestly, I'm not even sure what you mean by it.  Do you mean C++98?
>
> The string "ANSI" doesn't even appear on the wikipedia C++ page: :)
> <http://en.wikipedia.org/wiki/C%2B%2B>

Wikipedia isn't the only source of information,
http://www.cplusplus.com/info/faq/ talks about it, and
http://gcc.gnu.org/onlinedocs/gcc/Standards.html discusses the -ansi
flag, versus the -std=blah. I am not particularly tied to it, but it
is fairly widely used.
>
> Better to use these names IMNSHO:
> <http://en.wikipedia.org/wiki/C%2B%2B#Standardization>
>
>>This does change the default to
>>enable C++11 if the GCC compiler reports it is capable of this
>
> I would argue against forcing any particular dialect.  It seems to me that that should be an explicit choice made by the user at compile time.  Specially since VTK is a library.  If my app is built as C++98 and VTK 6.2 suddenly decides to build itself as C++11 then I could easily get freaky link errors because of changes to mangling, etc.

This is where I was less certain, although I am not aware of changes
in mangling for stuff we care about - do you have examples here, or
just being cautious? As far as I know the MSVC compilers enable all
new C++ features by default, whereas GCC/Clang need it to be enabled.
>
>>verified the VTK_OVERRIDE fails as expected when overriding something
>>that is not virtual. When looking at this it raised the question (for
>>me at least) of whether we ask for ANSI C++, and the standards (I
>>think we should), or the GNU specific extensions (what we were
>>implicitly doing before by passing nothing unless extra warnings were
>>turned on).
>
> As VTK is cross platform, best to use as few gcc extensions as possible, none ideally.
>
> clang has a warning that warns when gcc extensions are used, as I recall there are a few in the VTK codebase, like using C99 VLAs in C++ files.  I'll do a build and see how many warnings pop...

I doubt we have many, as we normally make people fix these in review
and they cause failures on Windows for example.

I guess we can go with explicitly enabling, but at some point we may
want to change this to the other way around. Otherwise you end up with
a bunch of features most developers/users never see/enable as they are
not aware of all the flags. Maybe we want a meta flag for VTK - enable
new stuff, as GCC visibility is off by default, extra compiler
warnings, possibly now new C++ features, and it is quite a list to
enable one-by-one.

We can take some time to mull it over, but I personally wouldn't mind
the enable all new features flag grouping.

Marcus



More information about the vtk-developers mailing list