cppcoro icon indicating copy to clipboard operation
cppcoro copied to clipboard

`task` example in README.md

Open YehezkelShB opened this issue 6 years ago • 3 comments

task<T> example in README.md includes the following line:

auto file = co_await cppcoro::read_only_file::open(path);

This doesn't compile and I can't even find a point in the git history that such a function existed. I guess this example started before the API was final and before the introduction of io_service.

YehezkelShB avatar Apr 10 '19 05:04 YehezkelShB

I was about to open another issue, but perhaps it's better to follow up this one, as they might be two cases of outdated documentation.

I'm new with coroutines and I'm learning by following the examples in the README.md page. I tried to compile the first example, adding a main(), but the compiler immediately stops issuing an error: apparently there's a misplaced endif in the last lines of the header file_read_operation.hpp

This is the message (/usr/local/include/ is where I installed cppcoro, clang is 7.0.1 on Fedora Linux)

clang++ -fcoroutines-ts -Wall -Wpedantic -Wextra -Wconversion -Weffc++ -std=c++2a -I /usr/local/include/ -stdlib=libc++ -c test.cpp

In file included from test.cpp:1: In file included from /usr/local/include/cppcoro/read_only_file.hpp:8: In file included from /usr/local/include/cppcoro/readable_file.hpp:9: /usr/local/include/cppcoro/file_read_operation.hpp:98:1: error: extraneous closing brace ('}') }

By inspecting the file it seems that the CPPCORO_OS_WINNT directive is closed too early. Is that OK? Is perhaps the example outdated and file_read_operation.hpp should never be used or am I missing something?

Furthermore, the same error mentioned by @YehezkelShB happens to me, with message:

test.cpp:8:58: error: too few arguments to function call, expected at least 2, have 1 auto file = co_await cppcoro::read_only_file::open(path); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ /usr/local/include/cppcoro/read_only_file.hpp:44:3: note: 'open' declared here static read_only_file open(

j-silver avatar Apr 11 '19 08:04 j-silver

Linux isn't supported yet for all the I/O stuff anyway (see #15), but the #ifdef would better be closed correctly, as preparation for such support to be implemented.

YehezkelShB avatar Apr 11 '19 08:04 YehezkelShB

Thanks. I didn't check the extension of Linux support. I guess I can wait a little bit more then...

j-silver avatar Apr 11 '19 12:04 j-silver