Skip to content

move to C++17#2718

Closed
salix5 wants to merge 2 commits into
Fluorohydride:masterfrom
salix5:cpp17
Closed

move to C++17#2718
salix5 wants to merge 2 commits into
Fluorohydride:masterfrom
salix5:cpp17

Conversation

@salix5

@salix5 salix5 commented Mar 8, 2025

Copy link
Copy Markdown
Collaborator

https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance?view=msvc-170
Most C++17 features are supported in VS2017~2019, which is at least 6 years ago.
Maybe it is time to move to C++17.

(update the conclusion in #2603)

some C++17 feautures we may need:

  • new helper functions
  • constexpr if
  • terse static assert
  • selection statements with initializer

related:
mercury233/irrlicht#7

@mercury233
@purerosefallen
@Wind2009-Louse
@fallenstardust

@purerosefallen

Copy link
Copy Markdown
Collaborator

Which version of GCC, or Linux distro, supports C++ 17? We have to consider server OS things.

@purerosefallen

Copy link
Copy Markdown
Collaborator

Any required changes on premake script?

@salix5

salix5 commented Mar 10, 2025

Copy link
Copy Markdown
Collaborator Author

https://gcc.gnu.org/projects/cxx-status.html#cxx17
GCC has almost full support for the 2017 revision of the C++ standard. The status of C++17 library features is described in the library documentation.

C++17 mode is the default since GCC 11

Any required changes on premake script?

No
Yes

@edo9300

edo9300 commented Mar 11, 2025

Copy link
Copy Markdown
Contributor

For premake, you should use the cppdialect option to pass the language version, and will take care of setting the compiler flags (there's an option for rtti as well)

@salix5

salix5 commented Mar 11, 2025

Copy link
Copy Markdown
Collaborator Author

For premake, you should use the cppdialect option to pass the language version, and will take care of setting the compiler flags (there's an option for rtti as well)

Thank you!
I don't know much about the flag "-fno-rtti", so I keep it for now.

@purerosefallen
The premake scripts are updated.

@purerosefallen

Copy link
Copy Markdown
Collaborator

does it work now?

@salix5

salix5 commented Apr 4, 2025

Copy link
Copy Markdown
Collaborator Author

yes

@yybbwc

yybbwc commented Apr 26, 2025

Copy link
Copy Markdown
Contributor

怎么还没合并……

@mercury233

Copy link
Copy Markdown
Collaborator

I think what we should do is fix the code to be compatible with the new C++ standard, rather than breaking compatibility with the old standard just to use some new features for non-essential functionality.

@salix5

salix5 commented May 12, 2025

Copy link
Copy Markdown
Collaborator Author

rather than breaking compatibility with the old standard just to use some new features for non-essential functionality.

like what?
can you give an example?

@mercury233

Copy link
Copy Markdown
Collaborator

like what? can you give an example?

constexpr if

I guess it will be optimized by compiler already

@salix5

salix5 commented May 12, 2025

Copy link
Copy Markdown
Collaborator Author

For the record, using new features in C++17 is not "breaking compatibility".
I guess people call it progress.

@salix5 salix5 closed this Jun 20, 2025
@salix5 salix5 deleted the cpp17 branch June 25, 2025 14:00
@mercury233 mercury233 mentioned this pull request Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants