Giter VIP home page Giter VIP logo

Comments (12)

bcoconni avatar bcoconni commented on May 25, 2024

That's an interesting option. I am not familiar with all the goodies brought by the last revisions of the C++ standard but there are a couple of interesting features in C++11:

  • constexpr
  • The type inference auto
  • The range based for loops

👍 to that proposal.

from jsbsim.

agodemar avatar agodemar commented on May 25, 2024

@bcoconni I like those new features as well as the std::unique_ptr and lambda functions. See for example here, here, here, or here.

My proposal: From now on switch to C++11, whether we are reviewing old code or we are adding new features to the library.

from jsbsim.

bcoconni avatar bcoconni commented on May 25, 2024

Since we are embedding the code of JSBSim in FlightGear and since they are using C++11, I suggest we do not use features of C++ earlier than C++11.

from jsbsim.

seanmcleod avatar seanmcleod commented on May 25, 2024

@bcoconni I presume you meant to write not later than C++11 (from 2011), i.e. don't use any features in C++14 or C++17?

from jsbsim.

bcoconni avatar bcoconni commented on May 25, 2024

@seanmcleod
Ooops ! Yes you are right, I meant later 😄

from jsbsim.

agodemar avatar agodemar commented on May 25, 2024

I propose this additional configuration in src/CMakeLists.txt

if(NOT CMAKE_VERSION VERSION_LESS 3.1)
    set(CMAKE_CXX_STANDARD 11)
else()
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()

from jsbsim.

bcoconni avatar bcoconni commented on May 25, 2024

@agodemar Is the flag -std=c++11 recognized by all compilers (Visual C++, gcc and clang) ?

from jsbsim.

agodemar avatar agodemar commented on May 25, 2024

from jsbsim.

bcoconni avatar bcoconni commented on May 25, 2024

Thanks.

So I guess Visual C++ will complain if we provide it with the flag -std=c++11 ? Which means that the code should be something like below (swapping the two if branches to save the negation NOT on the CMake version condition) ?

if (CMAKE_VERSION VERSION_LESS 3.1)
  if (NOT MSVC)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  endif()
else()
  set(CMAKE_CXX_STANDARD 11)
endif()

from jsbsim.

agodemar avatar agodemar commented on May 25, 2024

It should work.

There is no C++11 flag for Visual C++. For later versions of the standard the flags are: /std:c++14 and /std:c++17 (or /std:c++latest).

from jsbsim.

bcoconni avatar bcoconni commented on May 25, 2024

@agodemar
Will you push that change to master ? I suggest that you skip the pull request process and push directly to JSBSim:master

from jsbsim.

agodemar avatar agodemar commented on May 25, 2024

I've changed the title of this issue, which is now closed.

from jsbsim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.