forked from lewissbaker/cppcoro
-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
Hi
Try Build Sample project with gcc 11.2 in linux
my sample cmakelists.txt
cmake_minimum_required(VERSION 3.20)
project(app LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
add_compile_options(-std=c++20 -fcoroutines -fconcepts)
find_package(cppcoro CONFIG REQUIRED)
add_executable(app main.cpp)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
target_link_libraries(app PRIVATE cppcoro::cppcoro)
main.cpp
#include <cppcoro/task.hpp>
#include <cppcoro/task.hpp>
#include <cppcoro/io_service.hpp>
#include <cppcoro/read_only_file.hpp>
#include <cppcoro/filesystem.hpp>
#include <memory>
#include <algorithm>
#include <iostream>
namespace fs = cppcoro::filesystem;
cppcoro::task<std::uint64_t> count_lines(cppcoro::io_service& ioService, fs::path path)
{
auto file = cppcoro::read_only_file::open(ioService, path);
constexpr size_t bufferSize = 4096;
auto buffer = std::make_unique<std::uint8_t[]>(bufferSize);
std::uint64_t newlineCount = 0;
for (std::uint64_t offset = 0, fileSize = file.size(); offset < fileSize;)
{
const auto bytesToRead = static_cast<size_t>(
std::min<std::uint64_t>(bufferSize, fileSize - offset));
const auto bytesRead = co_await file.read(offset, buffer.get(), bytesToRead);
newlineCount += std::count(buffer.get(), buffer.get() + bytesRead, '\n');
offset += bytesRead;
}
co_return newlineCount;
}
i get som errors :
FAILED: CMakeFiles/app.dir/main.cpp.o
/usr/bin/c++ -isystem /home/mz/.local/include -std=c++20 -fcoroutines -fconcepts -std=c++20 -MD -MT CMakeFiles/app.dir/main.cpp.o -MF CMakeFiles/app.dir/main.cpp.o.d -o CMakeFiles/app.dir/main.cpp.o -c /mnt/N1/MZ/Prog/PC_CPP/Libs/cppcoro/Cppcoro_ex2/main.cpp
In file included from /home/mz/.local/include/cppcoro/readable_file.hpp:9,
from /home/mz/.local/include/cppcoro/read_only_file.hpp:8,
from /mnt/N1/MZ/Prog/PC_CPP/Libs/cppcoro/Cppcoro_ex2/main.cpp:4:
/home/mz/.local/include/cppcoro/file_read_operation.hpp:97:1: error: expected declaration before ‘}’ token
97 | }
| ^
In file included from /home/mz/.local/include/cppcoro/read_only_file.hpp:8,
from /mnt/N1/MZ/Prog/PC_CPP/Libs/cppcoro/Cppcoro_ex2/main.cpp:4:
/home/mz/.local/include/cppcoro/readable_file.hpp:47:17: error: ‘file_read_operation’ does not name a type
47 | file_read_operation read(
| ^~~~~~~~~~~~~~~~~~~
/home/mz/.local/include/cppcoro/readable_file.hpp:52:17: error: ‘file_read_operation_cancellable’ does not name a type
52 | file_read_operation_cancellable read(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/N1/MZ/Prog/PC_CPP/Libs/cppcoro/Cppcoro_ex2/main.cpp: In function ‘cppcoro::task<long unsigned int> count_lines(cppcoro::io_service&, std::filesystem::__cxx11::path)’:
/mnt/N1/MZ/Prog/PC_CPP/Libs/cppcoro/Cppcoro_ex2/main.cpp:27:42: error: ‘class cppcoro::read_only_file’ has no member named ‘read’
27 | const auto bytesRead = co_await file.read(offset, buffer.get(), bytesToRead);
| ^~~~
In file included from /mnt/N1/MZ/Prog/PC_CPP/Libs/cppcoro/Cppcoro_ex2/main.cpp:1:
/home/mz/.local/include/cppcoro/task.hpp:52:38: error: the expression ‘cppcoro::detail::task_promise_base::final_awaitable::await_suspend<cppcoro::detail::task_promise<long unsigned int> >’ is required to be non-throwing
52 | void await_suspend(cppcoro::coroutine_handle<PROMISE> coroutine)
| ^~~~~~~~~~~~~
/home/mz/.local/include/cppcoro/task.hpp:52:38: note: must be declared with ‘noexcept(true)’
/home/mz/.local/include/cppcoro/task.hpp: In function ‘cppcoro::task<void> run(cppcoro::io_service&)’:
/home/mz/.local/include/cppcoro/task.hpp:52:38: error: the expression ‘cppcoro::detail::task_promise_base::final_awaitable::await_suspend<cppcoro::detail::task_promise<void> >’ is required to be non-throwing
/home/mz/.local/include/cppcoro/task.hpp:52:38: note: must be declared with ‘noexcept(true)’
/home/mz/.local/include/cppcoro/task.hpp: In function ‘cppcoro::task<void> process_events(cppcoro::io_service&)’:
/home/mz/.local/include/cppcoro/task.hpp:52:38: error: the expression ‘cppcoro::detail::task_promise_base::final_awaitable::await_suspend<cppcoro::detail::task_promise<void> >’ is required to be non-throwing
/home/mz/.local/include/cppcoro/task.hpp:52:38: note: must be declared with ‘noexcept(true)’
/mnt/N1/MZ/Prog/PC_CPP/Libs/cppcoro/Cppcoro_ex2/main.cpp: In function ‘int main()’:
/mnt/N1/MZ/Prog/PC_CPP/Libs/cppcoro/Cppcoro_ex2/main.cpp:58:12: error: ‘sync_wait’ is not a member of ‘cppcoro’
58 | cppcoro::sync_wait(cppcoro::when_all_ready(
| ^~~~~~~~~
/mnt/N1/MZ/Prog/PC_CPP/Libs/cppcoro/Cppcoro_ex2/main.cpp:58:31: error: ‘when_all_ready’ is not a member of ‘cppcoro’
58 | cppcoro::sync_wait(cppcoro::when_all_ready(
| ^~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
Metadata
Metadata
Assignees
Labels
No labels