Skip to content

Compilation error: circular includes for static_thread_pool #1990

@dkolsen-pgi

Description

@dkolsen-pgi

Compiling a file on Linux where the first stdexec header included is <exec/static_thread_pool.hpp> and the macro STDEXEC_SYSTEM_CONTEXT_HEADER_ONLY is defined set up a circular include and leads to a compilation error about exec::static_thread_pool not being defined.

$ cat poolonly.cpp
#include <exec/static_thread_pool.hpp>
int main() { }
$ g++ -std=c++23 -DSTDEXEC_SYSTEM_CONTEXT_HEADER_ONLY -I/proj/cuda/stdexec/main/include poolonly.cpp -ltbb
In file included from /proj/cuda/stdexec/main/include/exec/../stdexec/__detail/__system_context_default_impl_entry.hpp:30,
                 from /proj/cuda/stdexec/main/include/exec/../stdexec/__detail/__parallel_scheduler.hpp:770,
                 from /proj/cuda/stdexec/main/include/exec/../stdexec/execution.hpp:44,
                 from /proj/cuda/stdexec/main/include/exec/static_thread_pool.hpp:25,
                 from poolonly.cpp:1:
/proj/cuda/stdexec/main/include/exec/../stdexec/__detail/__system_context_default_impl.hpp:393:66: error: ‘static_thread_pool’ is not a member of ‘exec’
  393 | ng __parallel_scheduler_backend_impl = __generic_impl<exec::static_thread_pool>;
      |                                                             ^~~~~~~~~~~~~~~~~~

The sequence of includes is:

exec/static_thread_pool.hpp
  stdexec/execution.hpp
    stdexec/__detail/__parallel_scheduler.hpp
      stdexec/__detail/__system_context_default_impl_entry.hpp
        stdexec/__detail/__system_context_default_impl.hpp
          exec/static_thread_pool.hpp

This has an easy enough workaround; just include <stdexec/execution.hpp> before <exec/static_thread_pool.h>. So I am not blocked. But this should be fixed (though I am not sure how best to do that).

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