Skip to content

DOC: Document which C++ standard is used for NumPy development. #21299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
WarrenWeckesser opened this issue Apr 5, 2022 · 3 comments
Closed
Labels
04 - Documentation 26 - Compiler C++ Related to introduction and use of C++ in the NumPy code base

Comments

@WarrenWeckesser
Copy link
Member

WarrenWeckesser commented Apr 5, 2022

I can't find a statement of which C++ standard is used for NumPy development. I know it is at least C++11, but I don't know if the use of a newer standard is allowed. This should be stated explicitly in https://github.com/numpy/numpy/blob/main/doc/source/user/building.rst

@WarrenWeckesser WarrenWeckesser added 04 - Documentation 26 - Compiler C++ Related to introduction and use of C++ in the NumPy code base labels Apr 5, 2022
@mattip
Copy link
Member

mattip commented Apr 5, 2022

There was some consensus at the time we discussed the acceptance of c++ to avoid c++ features like auto variables and lambda functions (if I am remembering correctly). This comment in PR 19713 refers to a triage meeting but the protocol is quite preliminary and not complete. this other comment refers to this meeting where it says "We should limit C++ explicitly, we can have clang-tidy", but the actual limitations were not set out. That PR also has a discussion about not using symbols from the c++ standard library to avoid the need to ship another dll/so.

I think we should document the use of templating, and additionally state which features we wish to avoid. By creating the document, we can finalize the discussion of the set of features that are acceptable/to be avoided.

@mattip
Copy link
Member

mattip commented Apr 8, 2022

There now is a short statement in build.rst, and the set of flags we use (NPY_CXX_FLAGS) can give an indication of what features we use and what features we avoid

# These flags are used to compile any C++ source within Numpy.
# They are chosen to have very few runtime dependencies.
NPY_CXX_FLAGS = [
'-std=c++11', # Minimal standard version
'-D__STDC_VERSION__=0', # for compatibility with C headers
'-fno-exceptions', # no exception support
'-fno-rtti'] # no runtime type information

@WarrenWeckesser
Copy link
Member Author

Thanks, @mattip. That covers the basic question of "Which C++ standard can be used?"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
04 - Documentation 26 - Compiler C++ Related to introduction and use of C++ in the NumPy code base
Projects
None yet
Development

No branches or pull requests

2 participants