cameron314 / cameron314/concurrentqueue
Linux fs.h causes compilation problems
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 12.5k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
/usr/include/linux/fs.h does this:
#define BLOCK_SIZE_BITS 10
#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
This definition of BLOCK_SIZE as a preprocessor constant causes subsequent use of concurrentqueue.h or blockingconcurrentqueue.h to not compile correctly, as BLOCK_SIZE is used in moodycamel::ConcurrentQueueDefaultTraits.
This is clearly a Linux / C issue, but it's not something that's likely to be fixable in <linux/fs.h>.
My workaround was #undef BLOCK_SIZE before including concurrentqueue.h. You might consider doing this by default in the header, as clearly a macro of that name is going to cause problems.
Another option would be to #error and at least noisily warn the user of the problem - the compiler errors appear nonsensical and give no real clue what the problem is, so it took me a while to track this down. I wasn't even including <linux/fs.h>, it was being transitively included by liburing.h, which in turn was a dependency for Boost.ASIO's BOOST_ASIO_HAS_IO_URING mode. So while I suspected a #define was to blame, it didn't actually appear in any source code or package dependencies.
vcpkg_installed/x64-linux-cpp20/include/concurrentqueue/concurrentqueue.h:343:29: error: expected unqualified-id before numeric constant
343 | static const size_t BLOCK_SIZE = 32;
| ^~~~~~~~~~
vcpkg_installed/x64-linux-cpp20/include/concurrentqueue/concurrentqueue.h:343:29: error: expected ‘)’ before numeric constant
343 | static const size_t BLOCK_SIZE = 32;
| ^~~~~~~~~~
I guess the other option would be change the name of the variable you use, but that's a back-compat problem for your own users seeing as it's a customisation point.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure by including linux/fs.h before concurrentqueue.h, then inspect ConcurrentQueueDefaultTraits in concurrentqueue.h and the related definitions in blockingconcurrentqueue.h. Compare the available compatibility approaches, including the customization point concern, and verify that the chosen behavior allows compilation without breaking existing users.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, linux
- Domain
- operating-systems, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100