Skip to content

Compile error: token is not a valid binary operator in a preprocessor subexpression #1638

@YanzhaoW

Description

@YanzhaoW

Hi,

I'm using the clang with libc++ to build my project using stdexec. I have compiled and installed stdexec, but when I consume the library in my project, I get lots of errors during the compilation (using the example main.cpp):

/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__config.hpp:20:23: error: token is not a valid binary operator in a preprocessor subexpression
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__config.hpp:137:33: error: token is not a valid binary operator in a preprocessor subexpression
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__config.hpp:293:69: error: token is not a valid binary operator in a preprocessor subexpression
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__config.hpp:381:68: error: token is not a valid binary operator in a preprocessor subexpression
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__config.hpp:392:47: error: token is not a valid binary operator in a preprocessor subexpression
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__config.hpp:425:53: error: token is not a valid binary operator in a preprocessor subexpression
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__config.hpp:439:57: error: token is not a valid binary operator in a preprocessor subexpression
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__config.hpp:447:75: error: token is not a valid binary operator in a preprocessor subexpression
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__config.hpp:453:64: error: token is not a valid binary operator in a preprocessor subexpression
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__config.hpp:459:64: error: token is not a valid binary operator in a preprocessor subexpression
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__config.hpp:491:85: error: token is not a valid binary operator in a preprocessor subexpression
In file included from /home/yanwang/test/cpp/stdexec/main.cpp:1:
In file included from /home/yanwang/software/stdexec/include/exec/static_thread_pool.hpp:20:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/execution.hpp:18:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__execution_fwd.hpp:19:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__meta.hpp:24:
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__concepts.hpp:18:26: error: token is not a valid binary operator in a preprocessor subexpression
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__concepts.hpp:28:60: error: token is not a valid binary operator in a preprocessor subexpression
In file included from /home/yanwang/test/cpp/stdexec/main.cpp:1:
In file included from /home/yanwang/software/stdexec/include/exec/static_thread_pool.hpp:20:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/execution.hpp:18:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__execution_fwd.hpp:19:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__meta.hpp:26:
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__utility.hpp:177:57: error: token is not a valid binary operator in a preprocessor subexpression
In file included from /home/yanwang/test/cpp/stdexec/main.cpp:1:
In file included from /home/yanwang/software/stdexec/include/exec/static_thread_pool.hpp:20:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/execution.hpp:21:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__as_awaitable.hpp:24:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__receivers.hpp:22:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__env.hpp:21:
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__cpo.hpp:85:68: error: token is not a valid binary operator in a preprocessor subexpression
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__cpo.hpp:93:51: error: token is not a valid binary operator in a preprocessor subexpression
In file included from /home/yanwang/test/cpp/stdexec/main.cpp:1:
In file included from /home/yanwang/software/stdexec/include/exec/static_thread_pool.hpp:20:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/execution.hpp:21:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__as_awaitable.hpp:24:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__receivers.hpp:22:
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__env.hpp:581:46: error: token is not a valid binary operator in a preprocessor subexpression
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__env.hpp:626:46: error: token is not a valid binary operator in a preprocessor subexpression
In file included from /home/yanwang/test/cpp/stdexec/main.cpp:1:
In file included from /home/yanwang/software/stdexec/include/exec/static_thread_pool.hpp:20:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/execution.hpp:30:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__ensure_started.hpp:26:
In file included from /home/yanwang/software/stdexec/include/exec/../stdexec/__detail/__shared.hpp:31:
/home/yanwang/software/stdexec/include/exec/../stdexec/__detail/../stop_token.hpp:28:61: error: token is not a valid binary operator in a preprocessor subexpression

I looked a little bit deeper and found that the error is caused the "digital separator" in the macros, which somehow my clang compiler doesn't support:

#if defined(__cpp_explicit_this_parameter) && (__cpp_explicit_this_parameter >= 2021'10L)
#  define STDEXEC_EXPLICIT_THIS() 1
#else
#  define STDEXEC_EXPLICIT_THIS() 0
#endif

Here if I change 2021'10L to 202110L, the error would be fixed.

I download the clang compiler directly from their apt repos: https://apt.llvm.org

My CMake options are:

cmake -DCMAKE_CXX_COMPILER=$(which clang-20) -DCMAKE_C_COMPILER=$(which clang-20) -DCMAKE_CXX_FLAGS="-stdlib=libc++" ..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions