Home > Enterprise >  Is C implementation of executor finalized? How to compile it?
Is C implementation of executor finalized? How to compile it?

Time:06-08

I'm trying to use C executor. This is the code I found in https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0443r14.html. It should be supported by gcc 11.

I compiled this code with command

g  -11 main.cpp -ltbb
#include <iostream>
#include <execution>
using namespace std::execution;

int main() {
  std::static_thread_pool pool(16);
  executor auto ex = pool.executor();
  perform_business_logic(ex);
  execute(ex, []{ std::cout << "Hello world from the thread pool!"; });
}

It gives a lot of errors.

error: ‘thread_pool’ is not a member of ‘std’
error: ‘executor’ was not declared in this scope
error: ‘ex’ was not declared in this scope

CodePudding user response:

This is just a proposal for addition to the C standard. It was never adopted.

See https://github.com/cplusplus/papers/issues/102 regarding the progress of this proposal which was closed and https://github.com/cplusplus/papers/issues/1054 for the executor proposal which is currently still under consideration for C 26.

Currently there is no equivalent in any C revision (published or drafting). It is unlikely that you will find a compiler/standard library supporting any of the proposals except maybe as experimental implementations for demonstration. In particular I am not sure what you base "It should be supported by gcc 11." on. (The original C 17 tag on the question also doesn't make sense, since the linked proposal is from 2020.)

  •  Tags:  
  • c
  • Related