boostorg / sort

Boost.Sort
51 stars 45 forks source link

boost/sort/block_indirect_sort/block_indirect_sort.hpp doesn't compile under VS2017 #60

Open PavelCelba opened 2 years ago

PavelCelba commented 2 years ago

Including #include "boost/sort/block_indirect_sort/block_indirect_sort.hpp" and using boost::sort::block_indirect_sort doesn't compile on VS2017 (C++17 compiler). There are following errors:

1>c:\views\conan\BoostHeaders\3.0.0+1.75.0\rs3\stable\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\boost/sort/common/spinlock.hpp(72): error C2065: 'not': undeclared identifier 1>c:\views\conan\BoostHeaders\3.0.0+1.75.0\rs3\stable\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\boost/sort/common/spinlock.hpp(72): error C2146: syntax error: missing ';' before identifier 'af'

Furthermore including: #include <boost/range/algorithm.hpp> along causes more errors since boost::sort is now template method and also internal namespace name used by block_indirect_sort.hpp header.

This is in boost 1.75.0, but I don't see it fixed in current version either (by brief look).

Morwenn commented 2 years ago

That's because MSVC doesn't support alternative keywords (not, and, or, etc.) in its default mode. It can probably be fixed in Boost.Sort itself, but in the meantime you can either compile with /permissive- or include <ciso646> before the Boost.Sort header (this small header defines the alternative keywords in MSVC).

PavelCelba commented 2 years ago

Yes, I know. I'm working on in-house library for big project. It's not so easy to mingle with compiler settings for whole codebase. So I'll in meantime use parallel sort from std. The other issue with sort method / namespace clash is however even more pesky.

Also to note there is a standard implementation of spinlock in boost. It maybe good idea to switch to that one instead of this custom and uncompilable one :-)

fjtapia commented 2 years ago

Probably, the solution is as easy as editing the file spinlock.hpp and adding #include .

The use of and, or, xor not instead of && || ^ or !, is included in the C++ standard, and the compilers support it natively, except Microsoft. If you want to use Visual C++, you must include the file ciso646. In other compilers, this file exists but it is empty.

I developed the code with GCC. When finished, I compiled with CLANG without problems. But when I tried to compile with VC++ 2019, appear a lot of errors, all related to the use of and, or. After a long and stupid process, I included the file in the headers, and all the code (test, examples, and benchmarks) compile and run correctly. You are using an older version, I suppose you are suffering the same. I just installed the last version of VC++, and continue with the same problem.

I will change the spinlock file in the repository adding the ciso646. If the error persists, please, say me and I will check in deep to detect and correct it. Thanks for your interest

Francisco

El lun, 13 jun 2022 a las 18:03, PavelCelba @.***>) escribió:

Including #include "boost/sort/block_indirect_sort/block_indirect_sort.hpp" and using boost::sort::block_indirect_sort doesn't compile on VS2017 (C++17 compiler). There are following errors:

1>c:\views\conan\BoostHeaders\3.0.0+1.75.0\rs3\stable\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\boost/sort/common/spinlock.hpp(72): error C2065: 'not': undeclared identifier 1>c:\views\conan\BoostHeaders\3.0.0+1.75.0\rs3\stable\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\boost/sort/common/spinlock.hpp(72): error C2146: syntax error: missing ';' before identifier 'af'

Furthermore including: #include <boost/range/algorithm.hpp> along causes more errors since boost::sort is now template method and also internal namespace name used by block_indirect_sort.hpp header.

This is in boost 1.75.0, but I don't see it fixed in current version either (by brief look).

— Reply to this email directly, view it on GitHub https://github.com/boostorg/sort/issues/60, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5O5GFN3IHZEUV3MHLAP5DVO5LUHANCNFSM5YUXC2EQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

PavelCelba commented 2 years ago

That's nice. Thou the other problem needs fixing too (which maybe harder to fix somehow): Furthermore including: #include <boost/range/algorithm.hpp> along causes more errors since boost::sort is now template method and also internal namespace name used by block_indirect_sort.hpp header.

fjtapia commented 2 years ago

The two errors are in the same line. Probably, fixing the first, fix the second. If it's not true. Say me and I will check in deep

El mar, 14 jun 2022 a las 13:31, PavelCelba @.***>) escribió:

That's nice. Thou the other problem needs fixing too (which maybe harder to fix somehow): Furthermore including: #include <boost/range/algorithm.hpp> along causes more errors since boost::sort is now template method and also internal namespace name used by block_indirect_sort.hpp header.

— Reply to this email directly, view it on GitHub https://github.com/boostorg/sort/issues/60#issuecomment-1155062009, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5O5GDIJHWZLFF45MN4ZV3VPBUSFANCNFSM5YUXC2EQ . You are receiving this because you commented.Message ID: @.***>

PavelCelba commented 2 years ago

For this:

Furthermore including: #include <boost/range/algorithm.hpp> along causes more errors since boost::sort is now template method and also internal namespace name used by block_indirect_sort.hpp header.

I have not included error messages in the first comment. But the problem is definitely there as described. And it's a different one!

PavelCelba commented 2 years ago

Reproducible for second problem - it's just enough to include files in some cpp and compile:

include "boost/sort/block_indirect_sort/block_indirect_sort.hpp"

include <boost/range/algorithm.hpp>

In this order it produces: 1>c:\views\conan\BoostHeaders\3.0.0+1.75.0\rs3\stable\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\boost/range/algorithm/sort.hpp(65): error C2874: using-declaration causes a multiple declaration of 'boost::range::sort'

In switched include order it produces: 1>c:\views\conan\BoostHeaders\3.0.0+1.75.0\rs3\stable\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\boost/sort/pdqsort/pdqsort.hpp(29): error C2757: 'sort': a symbol with this name already exists and therefore this name cannot be used as a namespace name

spreadsort commented 2 years ago

The second problem is because boost range doesn't follow the boost rules on namespaces. It is a bug with boost range: https://github.com/boostorg/range/issues/126. Feel free to comment there.