Skip to content

Preprocessor error with digit separators in C++20 modules dependency scanning #1934

@banderzhm

Description

@banderzhm

When using stdexec as a header-only library in a C++20 modules project, CMake's module dependency scanner fails with a
preprocessor error:

Error while scanning dependencies for /path/to/scheduler.cppm:
In file included from 3rdparty/stdexec/include/stdexec/__detail/__concepts.hpp:18:
error: token is not a valid binary operator in a preprocessor subexpression
#if __cpp_concepts < 2019'07L

Environment:

  • Compiler: Clang 21 / GCC 14
  • CMake: 4.1
  • Platform: WSL2 / Linux
  • C++ Standard: C++23
  • CMake setting: CMAKE_CXX_SCAN_FOR_MODULES ON

Root Cause:
The issue occurs during CMake's C++20 module dependency scanning phase. While modern compilers (Clang 21, GCC 14)
fully support digit separators (') in preprocessor expressions during normal compilation, the module dependency
scanner appears to use a different preprocessor mode that rejects digit separators in #if directives.

Affected Files:

  • include/stdexec/__detail/__concepts.hpp:18: #if __cpp_concepts < 2019'07L
  • include/stdexec/__detail/__config.hpp:20: #if __cplusplus < 2020'02L
  • include/stdexec/__detail/__config.hpp:619: #if __has_include() && __cpp_lib_concepts >= 2020'02L
  • include/exec/detail/intrusive_heap.hpp:31: #if defined(__cpp_lib_int_pow2) && __cpp_lib_int_pow2 >= 2020'02L
    may be many more ......

Workaround:
Replace digit separators with plain numeric literals:

  • 2019'07L → 201907L
  • 2020'02L → 202002L

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