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

error compilation with clang 6.0.1 : 4 errors generated #84

Closed
marcoippolito opened this issue Jun 5, 2018 · 1 comment
Closed

error compilation with clang 6.0.1 : 4 errors generated #84

marcoippolito opened this issue Jun 5, 2018 · 1 comment

Comments

@marcoippolito
Copy link

marcoippolito commented Jun 5, 2018

Hi,

`clang -v
 clang version 6.0.1-svn333623-1~exp1~20180604222746.83 (branches/release_60)
`

I'm trying to compile with clang my very first example of cppcoro usage in my Ubuntu 16.04 Server Edition:

  `#include <cppcoro/read_only_file.hpp>
  #include <cppcoro/task.hpp>
  cppcoro::task<int> count_lines(std::string path)
  {
  auto file = co_await cppcoro::read_only_file::open(path);
  int lineCount = 0;
  char buffer[1024];
  size_t bytesRead;
  std::uint64_t offset = 0;
  do
  {
    bytesRead = co_await file.read(offset, buffer, sizeof(buffer));
    lineCount += std::count(buffer, buffer + bytesRead, '\n');
    offset += bytesRead;
  } while (bytesRead > 0);
  co_return lineCount;
}
cppcoro::task<> usage_example()
{
  // Calling function creates a new task but doesn't start
  // executing the coroutine yet.
  cppcoro::task<int> countTask = count_lines("foo.txt");
  // ...
// Coroutine is only started when we later co_await the task.
  int lineCount = co_await countTask;
  std::cout << "line count = " << lineCount << std::endl;
}
`

`clang++ -std=c++17 -fcoroutines-ts -stdlib=libc++ -Wall -pedantic coroExample01.cpp 
-ocoroExample01 -lc++experimental
In file included from coroExample01.cpp:1:
In file included from /usr/include/cppcoro/read_only_file.hpp:8:
/usr/include/cppcoro/readable_file.hpp:47:3: error: unknown type name 'file_read_operation'
                file_read_operation read(
                ^
/usr/include/cppcoro/readable_file.hpp:52:3: error: unknown type name 
' file_read_operation_cancellable'
                file_read_operation_cancellable read(
                ^
coroExample01.cpp:6: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/include/cppcoro/read_only_file.hpp:44:3: note: 'open' declared here
                static read_only_file open(
                ^
3 errors generated.
`

What am I missing?
Marco

@marcoippolito marcoippolito changed the title error compilation with clang 6.0.1 : #include <experimental/filesystem> error compilation with clang 6.0.1 : 4 errors generated Jun 8, 2018
@lewissbaker
Copy link
Owner

Hi @marcoippolito, thanks for the issue.

This particular sample currently isn’t supported on Linux as the file I/O abstractions are currently only implemented for Windows.

There is some progress towards implementing Linux I/O support in #64 but I still need to do a bit more work on it. The rest of the non-I/O abstractions should work ok under Linux/Clang.

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