【发布时间】:2019-04-08 13:23:46
【问题描述】:
我编译如下代码:
#include <iostream>
#include <boost/beast.hpp>
int main()
{
std::cout << "Hello, world!\n";
}
通过
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85
$ nvcc -O0 --std=c++14 -g -Xcompiler=-Wfatal-errors -I./include -I../boost main.cu -o runserver
我得到编译器错误:
boost/beast/core/impl/error.ipp(20): warning: overloaded virtual function "boost::system::error_category::message" is only partially overridden in class "boost::beast::detail::error_codes"
beast/core/impl/error.ipp(55): warning: overloaded virtual function "boost::system::error_category::message" is only partially overridden in class "boost::beast::detail::error_conditions"
boost/beast/core/impl/error.ipp(84): warning: invalid narrowing conversion from "unsigned int" to "int"
boost/beast/core/impl/error.ipp(92): warning: invalid narrowing conversion from "unsigned int" to "int"
boost/asio/impl/error.ipp(32): warning: overloaded virtual function "boost::system::error_category::message" is only partially overridden in class "boost::asio::error::detail::netdb_category"
boost/asio/impl/error.ipp(64): warning: overloaded virtual function "boost::system::error_category::message" is only partially overridden in class "boost::asio::error::detail::addrinfo_category"
boost/asio/impl/error.ipp(94): warning: overloaded virtual function "boost::system::error_category::message" is only partially overridden in class "boost::asio::error::detail::misc_category"
boost/beast/http/impl/error.ipp(21): warning: overloaded virtual function "boost::system::error_category::message" is only partially overridden in class "boost::beast::http::detail::http_error_category"
boost/beast/http/impl/error.ipp(96): warning: invalid narrowing conversion from "unsigned int" to "int"
boost/beast/websocket/impl/error.ipp(20): warning: overloaded virtual function "boost::system::error_category::message" is only partially overridden in class "boost::beast::websocket::detail::error_codes"
boost/beast/websocket/impl/error.ipp(117): warning: overloaded virtual function "boost::system::error_category::message" is only partially overridden in class "boost::beast::websocket::detail::error_conditions"
boost/beast/websocket/impl/error.ipp(144): warning: invalid narrowing conversion from "unsigned int" to "int"
boost/beast/websocket/impl/error.ipp(152): warning: invalid narrowing conversion from "unsigned int" to "int"
boost/beast/zlib/impl/error.ipp(49): warning: overloaded virtual function "boost::system::error_category::message" is only partially overridden in class "boost::beast::zlib::detail::error_codes"
boost/beast/zlib/impl/error.ipp(115): warning: invalid narrowing conversion from "unsigned int" to "int"
boost/beast/http/message.hpp(265): error: static assertion failed with "Fields type requirements not met"
detected during:
instantiation of class "boost::beast::http::header<false, Fields> [with Fields=boost::beast::http::fields]"
(495): here
instantiation of class "boost::beast::http::message<isRequest, Body, Fields> [with isRequest=false, Body=boost::beast::http::string_body, Fields=boost::beast::http::fields]"
boost/beast/websocket/detail/impl_base.hpp(199): here
boost/beast/http/message.hpp(61): error: static assertion failed with "Fields type requirements not met"
detected during:
instantiation of class "boost::beast::http::header<true, Fields> [with Fields=boost::beast::http::fields]"
(495): here
instantiation of class "boost::beast::http::message<isRequest, Body, Fields> [with isRequest=true, Body=boost::beast::http::empty_body, Fields=boost::beast::http::fields]"
boost/beast/websocket/detail/impl_base.hpp(257): here
2 errors detected in the compilation of "/tmp/tmpxft_00002a42_00000000-6_main.cpp1.ii".
但是,如果我将文件后缀更改为.cpp并使用nvcc编译,则没有遇到任何问题,一切都很好。
为什么?我以为 nvcc 只是将 CPU 代码转发给主机编译器。
此外,似乎 nvcc 的 .ipp 文件有问题。这是一个已知问题吗?
【问题讨论】: