增强UE4插件中的野兽集成问题?

时间:2018-11-09 17:29:52

标签: c++ boost unreal-engine4 boost-beast

我正在尝试创建UE4插件,然后可以像使用Boost Beast client example那样简单地创建一个蓝图函数:

void UBoostBPFunctionLibrary::ConnectWebsocket(FString inMessage, FString& outResStr)
{
    //using tcp = boost::asio::ip::tcp;               // from <boost/asio/ip/tcp.hpp>
    //namespace websocket = boost::beast::websocket;  // from <boost/beast/websocket.hpp>

    //auto const host = "127.0.0.1";
    //auto const port = "8080";
    //std::string text(TCHAR_TO_ANSI(*inMessage));

    //// The io_context is required for all I/O
    //boost::asio::io_context ioc;

    //// These objects perform our I/O
    //tcp::resolver resolver{ ioc };
    //websocket::stream<tcp::socket> ws{ ioc };

    //// Look up the domain name
    //auto const results = resolver.resolve(host, port);

    //// Make the connection on the IP address we get from a lookup
    //boost::asio::connect(ws.next_layer(), results.begin(), results.end());

    //// Perform the websocket handshake
    //ws.handshake(host, "/");

    //// Send the message
    //ws.write(boost::asio::buffer(std::string(text)));

    //// This buffer will hold the incoming message
    //boost::beast::multi_buffer buffer;

    //// Read a message into our buffer
    //ws.read(buffer);

    //// Close the WebSocket connection
    //ws.close(websocket::close_code::normal);

    ////// If we get here then the connection is closed gracefully
    ////    // The buffers() function helps print a ConstBufferSequence
    //outResStr = FString(boost::beast::to_static_string(boost::beast::buffers(buffer.data())).c_str());
}

但是当我尝试通过在BoostBPFunctionLibrary.h中包含以下头文件来简单地进行编译时:

#include <boost/beast/core.hpp>
#include <boost/beast/websocket.hpp>
#include <boost/asio/connect.hpp>
#include <boost/asio/ip/tcp.hpp>

我收到很多错误,例如以下内容。我猜这些错误都指向“ AssertionMacros.h”及其任何增强版本中支票定义的冲突,但是接下来的问题是我如何解决该问题并使它起作用?为什么两个定义之间没有明确的基本区别?我试图删除第一个错误行指出的“检查功能”的增强版本,但是这会破坏boost中的其他代码文件,我试图对UE4这样做,但答案仍然是“否”。我觉得这里根本有问题。请指教。

2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/list.hpp(1333): error C4003: not enough arguments for function-like macro invocation 'check'
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/list.hpp(1333): error C2062: type 'void' unexpected
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/list.hpp(1405): note: see reference to class template instantiation 'boost::intrusive::list_impl<ValueTraits,SizeType,ConstantTimeSize,HeaderHolder>' being compiled
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/list.hpp(1333): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/list.hpp(1334): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/list.hpp(1334): error C2059: syntax error: '{'
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/list.hpp(1334): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree_algorithms.hpp(1452): warning C4002: too many arguments for function-like macro invocation 'check'
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree_algorithms.hpp(1452): error C2988: unrecognizable template declaration/definition
2>  C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree_algorithms.hpp(2074): note: see reference to class template instantiation 'boost::intrusive::bstree_algorithms<NodeTraits>' being compiled
2>  C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/beast/core/string.hpp(87): note: see reference to class template instantiation 'boost::basic_string_view<char,std::char_traits<char>>' being compiled
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree_algorithms.hpp(1452): error C2059: syntax error: '<end Parse>'
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree_algorithms.hpp(1452): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree_algorithms.hpp(1453): error C2988: unrecognizable template declaration/definition
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree_algorithms.hpp(1453): error C2059: syntax error: '{'
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree_algorithms.hpp(1453): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2074): error C4003: not enough arguments for function-like macro invocation 'check'
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2057): error C2988: unrecognizable template declaration/definition
2>  C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2122): note: see reference to class template instantiation 'boost::intrusive::bstree_impl<ValueTraits,VoidOrKeyOfValue,VoidOrKeyComp,SizeType,ConstantTimeSize,AlgoType,HeaderHolder>' being compiled
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2057): error C2059: syntax error: '<end Parse>'
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2057): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2058): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2058): error C2988: unrecognizable template declaration/definition
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2058): error C2059: syntax error: '{'
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2058): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2074): error C2062: type 'void' unexpected
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2074): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2075): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2075): error C2988: unrecognizable template declaration/definition
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2075): error C2059: syntax error: '{'
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2075): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2081): error C2988: unrecognizable template declaration/definition
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2081): error C2059: syntax error: 'if'
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2081): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2084): error C2988: unrecognizable template declaration/definition
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2084): error C2059: syntax error: 'return'
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2084): error C2238: unexpected token(s) preceding ';'
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2087): error C2255: 'friend': not allowed outside of a class definition
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/intrusive/bstree.hpp(2087): error C2144: syntax error: 'bool' should be preceded by ';'
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/beast/http/detail/type_traits.hpp(36): error C2988: unrecognizable template declaration/definition
2>  C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/beast/http/detail/type_traits.hpp(41): note: see reference to class template instantiation 'boost::beast::http::detail::is_header_impl<T>' being compiled
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/beast/http/detail/type_traits.hpp(36): error C2059: syntax error: '<end Parse>'
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/beast/http/detail/type_traits.hpp(36): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/beast/http/detail/type_traits.hpp(38): error C2226: syntax error: unexpected type 'std::false_type'
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/beast/http/detail/type_traits.hpp(38): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
2>C:\Users\Alam Syed\Documents\Unreal Projects\SomeProject\Plugins\PCL\Source\PCL\Boost\include\boost-root\boost/beast/http/detail/type_traits.hpp(40): error C2760: syntax error: unexpected token '{', expected 'expression'
2>  Module.PCL.cpp

1 个答案:

答案 0 :(得分:0)

有一个答案-关于为什么在unreal Engine forums for library macro conflicts.中发生这种情况的一种解释。有一个肮脏的解决方法可以尝试。