Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not build Sample Project with gcc 11.2 in linux #42

Open
Maziar123 opened this issue Apr 23, 2022 · 5 comments
Open

Can not build Sample Project with gcc 11.2 in linux #42

Maziar123 opened this issue Apr 23, 2022 · 5 comments

Comments

@Maziar123
Copy link

Maziar123 commented Apr 23, 2022

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.
@Maziar123 Maziar123 changed the title Can not build with gcc 11.2 Can not build Sample Project with gcc 11.2 Apr 23, 2022
@Maziar123 Maziar123 changed the title Can not build Sample Project with gcc 11.2 Can not build Sample Project with gcc 11.2 in linux Apr 23, 2022
@andreasbuhr
Copy link
Owner

Yes, file IO is only supported on Windows right now.

@Maziar123
Copy link
Author

Maziar123 commented Jun 24, 2023

But what clear way to build without File IO in Linux?

@andreasbuhr
Copy link
Owner

If you don't include any file-io files, it should work.

Otherwise, could you provide a complete CPP file which does not compile while it should?

@Maziar123
Copy link
Author

You Can See my sample in UP! ☝️

@andreasbuhr
Copy link
Owner

You example includes read_only_file.hpp, so it is not supposed to work on Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants