Fix BLOCK_SIZE macro conflict with system headers#443
Open
caomengxuan666 wants to merge 1 commit intocameron314:masterfrom
Open
Fix BLOCK_SIZE macro conflict with system headers#443caomengxuan666 wants to merge 1 commit intocameron314:masterfrom
caomengxuan666 wants to merge 1 commit intocameron314:masterfrom
Conversation
When including system headers like <linux/fs.h> which define BLOCK_SIZE as a macro (usually 1024), it conflicts with the BLOCK_SIZE constant in concurrentqueue. This causes compilation errors. Add push/pop macro guards around the entire file to temporarily undefine BLOCK_SIZE if it exists, and restore it after. This is a common issue when using concurrentqueue with io_uring or other Linux headers that define BLOCK_SIZE. The fix uses #pragma push_macro/ pop_macro which is supported by GCC, Clang, and MSVC.
9c96ccb to
f8fda36
Compare
Owner
|
Can't merge this, sorry. BLOCK_SIZE is part of the public API, it's not just used in the header (otherwise I could just rename it). If you're not using BLOCK_SIZE in your code to initialize queue traits, just include fs.h after concurrentqueue.h. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When including system headers like
<linux/fs.h>which define BLOCK_SIZE as a macro (usually 1024), it conflicts with the BLOCK_SIZE constant in concurrentqueue. This causes compilation errors:Add push/pop macro guards around the entire file to temporarily undefine BLOCK_SIZE if it exists, and restore it after.
This is a common issue when using concurrentqueue with io_uring or other Linux headers that define BLOCK_SIZE. The fix uses
#pragma push_macro/pop_macrowhich is supported by GCC, Clang, and MSVC.Testing: Tested with the following code:
The code compiles successfully and BLOCK_SIZE is correctly restored after including the headers.