Skip to content

Drop namespace std#3067

Merged
davisking merged 1 commit intodavisking:masterfrom
penguinpee:gcc15
Mar 16, 2025
Merged

Drop namespace std#3067
davisking merged 1 commit intodavisking:masterfrom
penguinpee:gcc15

Conversation

@penguinpee
Copy link
Contributor

Solve build error when compiling with GCC 15.

Solve build error when compiling with GCC 15.
@penguinpee
Copy link
Contributor Author

Compiling the Python module with GCC 15 resulted in:

  /builddir/build/BUILD/dlib-19.24.8-build/dlib-19.24.8/tools/python/src/sequence_segmenter.cpp:100:5: error: reference to ‘ranges’ is ambiguous
    100 |     ranges segment_sequence_dense (
        |     ^~~~~~
  In file included from /builddir/build/BUILD/dlib-19.24.8-build/dlib-19.24.8/dlib/../dlib/matrix/../fft/fft_size.h:6,
                   from /builddir/build/BUILD/dlib-19.24.8-build/dlib-19.24.8/dlib/../dlib/matrix/../fft/fft.h:7,
                   from /builddir/build/BUILD/dlib-19.24.8-build/dlib-19.24.8/dlib/../dlib/matrix/matrix_fft.h:11,
                   from /builddir/build/BUILD/dlib-19.24.8-build/dlib-19.24.8/dlib/../dlib/matrix/matrix_conv.h:8,
                   from /builddir/build/BUILD/dlib-19.24.8-build/dlib-19.24.8/dlib/../dlib/matrix.h:13,
                   from /builddir/build/BUILD/dlib-19.24.8-build/dlib-19.24.8/dlib/../dlib/python/numpy_image.h:8,
                   from /builddir/build/BUILD/dlib-19.24.8-build/dlib-19.24.8/dlib/../dlib/python.h:9,
                   from /builddir/build/BUILD/dlib-19.24.8-build/dlib-19.24.8/tools/python/src/opaque_types.h:6,
                   from /builddir/build/BUILD/dlib-19.24.8-build/dlib-19.24.8/tools/python/src/sequence_segmenter.cpp:4:
  /usr/include/c++/15/numeric:735:11: note: candidates are: ‘namespace std::ranges { }’
    735 | namespace ranges
        |           ^~~~~~
  /builddir/build/BUILD/dlib-19.24.8-build/dlib-19.24.8/tools/python/src/sequence_segmenter.cpp:15:63: note:                 ‘typedef class std::vector<std::pair<long unsigned int, long unsigned int> > ranges’
     15 | typedef std::vector<std::pair<unsigned long, unsigned long> > ranges;
        |                                                               ^~~~~~
  /builddir/build/BUILD/dlib-19.24.8-build/dlib-19.24.8/tools/python/src/sequence_segmenter.cpp:118:5: error: reference to ‘ranges’ is ambiguous
    118 |     ranges segment_sequence_sparse (
        |     ^~~~~~

The referenced candidate namespace std::ranges { } was introduced in <numeric> in GCC 15. It was not part of GCC 14, though upstream considers backporting.

@penguinpee
Copy link
Contributor Author

penguinpee commented Mar 14, 2025

Having looked a bit closer at the other source files in tools/python/src, the issue could also be solved with the approach used in matrix.cpp. That is including <dlib/string.h> and replacing using namespace std; with using std::string; and using std::ostringstream;.

I'm open to suggestions (not a C/C++ expert, nor very familiar with the code base).

@davisking
Copy link
Owner

Thanks for the PR :D

What you did is a fine way to deal with the issue.

@davisking davisking merged commit 427d2d3 into davisking:master Mar 16, 2025
10 checks passed
davisking pushed a commit to kSkip/dlib that referenced this pull request Apr 19, 2025
Solve build error when compiling with GCC 15.
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.

2 participants