[vtkusers] C++ 11 compiler issues with Makefile generate using cmake

Shawn Waldon shawn.waldon at kitware.com
Wed Aug 3 10:42:56 EDT 2016


Hi Chiranjib,

It could be one of several things.  First I would run make VERBOSE=1 to see
if the -std=c++0x is getting into the compile command correctly.  If it is,
then I would check if your compiler supports that feature.  Especially when
using the older compiler versions (the ones that use c++0x rather than
c++11) some language features may not be supported.

HTH,
Shawn

Also, adding the C++11 flags directly in the CMakeLists is not really the
recommended way to tell CMake to use C++11.  See these links (help pages
for the CMake variables you probably want) for the recommended way to do it
[1][2].

[1]: https://cmake.org/cmake/help/v3.6/variable/CMAKE_CXX_STANDARD.html
[2]:
https://cmake.org/cmake/help/v3.6/variable/CMAKE_CXX_STANDARD_REQUIRED.html

On Wed, Aug 3, 2016 at 6:00 AM, Chiranjib Sur <sur.chiranjib at gmail.com>
wrote:

> Hi,
> In my C++ code I am initialising my data members in the header file
> (example below)
>
> class foo{
> public:
>  int myInt =0;
> ....
> }
>
> When I create the Makefile using cmake, and try to compile the compiler
> trows an error that
>
>  error: ISO C++ forbids initialization of member ?myInt?
>
> I am using the "-std=c++0x" flag in my CMakeLists.txt file.
>
> This is a standard feature and I am puzzled why the compiler is
> complaining with the CMake generate Makefile.
>
> Any expert comments?
>
> Thanks,
> Chiranjib
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160803/95b59e08/attachment.html>


More information about the vtkusers mailing list