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

Undeclared uv enum values. #227

Closed
Yuhanun opened this issue Oct 21, 2020 · 4 comments
Closed

Undeclared uv enum values. #227

Yuhanun opened this issue Oct 21, 2020 · 4 comments
Assignees
Labels

Comments

@Yuhanun
Copy link

Yuhanun commented Oct 21, 2020

Hello,

I'm currently trying to build the library:

#include <uvw.hpp>
#include <memory>

void listen(uvw::Loop &loop) {
    std::shared_ptr<uvw::TCPHandle> tcp = loop.resource<uvw::TCPHandle>();

    tcp->once<uvw::ListenEvent>([](const uvw::ListenEvent &, uvw::TCPHandle &srv) {
        std::shared_ptr<uvw::TCPHandle> client = srv.loop().resource<uvw::TCPHandle>();

        client->on<uvw::CloseEvent>([ptr = srv.shared_from_this()](const uvw::CloseEvent &, uvw::TCPHandle &) { ptr->close(); });
        client->on<uvw::EndEvent>([](const uvw::EndEvent &, uvw::TCPHandle &client) { client.close(); });

        srv.accept(*client);
        client->read();
    });

    tcp->bind("127.0.0.1", 4242);
    tcp->listen();
}

void conn(uvw::Loop &loop) {
    auto tcp = loop.resource<uvw::TCPHandle>();

    tcp->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TCPHandle &) { /* handle errors */ });

    tcp->once<uvw::ConnectEvent>([](const uvw::ConnectEvent &, uvw::TCPHandle &tcp) {
        auto dataWrite = std::unique_ptr<char[]>(new char[2]{ 'b', 'c' });
        tcp.write(std::move(dataWrite), 2);
        tcp.close();
    });

    tcp->connect(std::string{"127.0.0.1"}, 4242);
}

int main() {
    auto loop = uvw::Loop::getDefault();
    listen(*loop);
    conn(*loop);
    loop->run();
}

However, the following error is thrown:

In file included from ../main.cpp:1:
In file included from ../thirdparty/uvw/src/uvw.hpp:1:
In file included from ../thirdparty/uvw/src/uvw/async.h:6:
In file included from ../thirdparty/uvw/src/uvw/handle.hpp:9:
In file included from ../thirdparty/uvw/src/uvw/resource.hpp:8:
In file included from ../thirdparty/uvw/src/uvw/underlying_type.hpp:8:
../thirdparty/uvw/src/uvw/loop.h:43:17: error: use of undeclared identifier 'UV_METRICS_IDLE_TIME'
    IDLE_TIME = UV_METRICS_IDLE_TIME
                ^
In file included from ../main.cpp:1:
In file included from ../thirdparty/uvw/src/uvw.hpp:1:
In file included from ../thirdparty/uvw/src/uvw/async.h:6:
In file included from ../thirdparty/uvw/src/uvw/handle.hpp:9:
In file included from ../thirdparty/uvw/src/uvw/resource.hpp:8:
In file included from ../thirdparty/uvw/src/uvw/underlying_type.hpp:8:
In file included from ../thirdparty/uvw/src/uvw/loop.h:430:
../thirdparty/uvw/src/uvw/loop.cpp:101:17: error: use of undeclared identifier 'uv_metrics_idle_time'
    return Time{uv_metrics_idle_time(loop.get())};
                ^
In file included from ../main.cpp:1:
In file included from ../thirdparty/uvw/src/uvw.hpp:6:
../thirdparty/uvw/src/uvw/fs.h:59:14: error: use of undeclared identifier 'UV_FS_LUTIME'
    LUTIME = UV_FS_LUTIME
             ^
In file included from ../main.cpp:1:
In file included from ../thirdparty/uvw/src/uvw.hpp:6:
In file included from ../thirdparty/uvw/src/uvw/fs.h:1459:
../thirdparty/uvw/src/uvw/fs.cpp:316:23: error: use of undeclared identifier 'uv_fs_lutime'
    cleanupAndInvoke(&uv_fs_lutime, parent(), get(), path.data(), atime.count(), mtime.count(), &fsGenericCallback<Type::LUTIME>);
                      ^
../thirdparty/uvw/src/uvw/fs.cpp:322:27: error: use of undeclared identifier 'uv_fs_lutime'
    cleanupAndInvokeSync(&uv_fs_lutime, parent(), req, path.data(), atime.count(), mtime.count());
                          ^
In file included from ../main.cpp:1:
In file included from ../thirdparty/uvw/src/uvw.hpp:22:
In file included from ../thirdparty/uvw/src/uvw/timer.h:113:
../thirdparty/uvw/src/uvw/timer.cpp:48:17: error: use of undeclared identifier 'uv_timer_get_due_in'; did you mean 'uv_timer_get_repeat'?
    return Time{uv_timer_get_due_in(get())};
                ^~~~~~~~~~~~~~~~~~~
                uv_timer_get_repeat
/usr/include/uv.h:853:20: note: 'uv_timer_get_repeat' declared here
UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle);
                   ^
In file included from ../main.cpp:1:
In file included from ../thirdparty/uvw/src/uvw.hpp:24:
../thirdparty/uvw/src/uvw/udp.h:49:22: error: use of undeclared identifier 'UV_UDP_MMSG_CHUNK'
    UDP_MMSG_CHUNK = UV_UDP_MMSG_CHUNK,
                     ^
../thirdparty/uvw/src/uvw/udp.h:50:21: error: use of undeclared identifier 'UV_UDP_MMSG_FREE'
    UDP_MMSG_FREE = UV_UDP_MMSG_FREE,
                    ^
../thirdparty/uvw/src/uvw/udp.h:51:20: error: use of undeclared identifier 'UV_UDP_RECVMMSG'
    UDP_RECVMMSG = UV_UDP_RECVMMSG
                   ^
In file included from ../main.cpp:1:
In file included from ../thirdparty/uvw/src/uvw.hpp:1:
In file included from ../thirdparty/uvw/src/uvw/async.h:6:
In file included from ../thirdparty/uvw/src/uvw/handle.hpp:6:
In file included from /bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/utility:70:
In file included from /bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_pair.h:59:
In file included from /bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/move.h:57:
/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/type_traits:2957:5: error: no type named 'type' in 'std::invoke_result<int (*)(uv_loop_s *, uv_fs_s *, int, double, double, void (*)(uv_fs_s *)), uv_loop_s *, uv_fs_s *, char *, double, double, void (*)(uv_fs_s *)>'
    using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
    ^~~~~
../thirdparty/uvw/src/uvw/request.hpp:38:42: note: in instantiation of template type alias 'invoke_result_t' requested here
        if constexpr(std::is_void_v<std::invoke_result_t<F, Args...>>) {
                                         ^
../thirdparty/uvw/src/uvw/fs.h:406:15: note: in instantiation of function template specialization 'uvw::Request<uvw::FsReq, uv_fs_s>::invoke<int (*)(uv_loop_s *, uv_fs_s *, int, double, double, void (*)(uv_fs_s *)), uv_loop_s *, uv_fs_s *, char *, double, double, void (*)(uv_fs_s *)>' requested here
        this->invoke(std::forward<Args>(args)...);
              ^
../thirdparty/uvw/src/uvw/fs.cpp:316:5: note: in instantiation of function template specialization 'uvw::FsRequest<uvw::FsReq>::cleanupAndInvoke<int (*)(uv_loop_s *, uv_fs_s *, int, double, double, void (*)(uv_fs_s *)), uv_loop_s *, uv_fs_s *, char *, double, double, void (*)(uv_fs_s *)>' requested here
    cleanupAndInvoke(&uv_fs_lutime, parent(), get(), path.data(), atime.count(), mtime.count(), &fsGenericCallback<Type::LUTIME>);
    ^
In file included from ../main.cpp:1:
In file included from ../thirdparty/uvw/src/uvw.hpp:6:
../thirdparty/uvw/src/uvw/fs.h:412:28: error: cannot initialize a parameter of type 'int' with an rvalue of type 'char *'
        std::forward<F>(f)(std::forward<Args>(args)..., nullptr);
                           ^~~~~~~~~~~~~~~~~~~~~~~~
../thirdparty/uvw/src/uvw/fs.cpp:322:5: note: in instantiation of function template specialization 'uvw::FsRequest<uvw::FsReq>::cleanupAndInvokeSync<int (*)(uv_loop_s *, uv_fs_s *, int, double, double, void (*)(uv_fs_s *)), uv_loop_s *, uv_fs_s *&, char *, double, double>' requested here
    cleanupAndInvokeSync(&uv_fs_lutime, parent(), req, path.data(), atime.count(), mtime.count());
    ^
11 errors generated.
[80/120] Building CXX object thirdparty/uvw/test/CMakeFiles/main.dir/main.cpp.o

This code example is quite literally the code from your readme.

Thank you

@stefanofiorentino
Copy link
Collaborator

Ciao @Yuhanun, can you show us the cmake configuration flags?

@stefanofiorentino
Copy link
Collaborator

@Yuhanun any news on this, I'll go closing it as seems just a misconfiguration in cmake options and/or a different version of libuv installed in discoverable/system path. Feel free to reopen it if you're still experiencing this issue.

@Yuhanun
Copy link
Author

Yuhanun commented Oct 26, 2020

Issue persis, ill send configuration flags later today.

@stefanofiorentino
Copy link
Collaborator

stefanofiorentino commented Oct 26, 2020

@Yuhanun the missing flags in your error output have been introduced/changed during last three months. So consider removing any other version installed and discoverable by CMake from your system. Hope this helps.

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

No branches or pull requests

2 participants