Boost beast integration issues in UE4 plugin?

713 Views Asked by At

I am trying to create a UE4 plugin then I can simply create a blueprint function like so using 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());
}

But as I try to compile simply by including the following header files in my BoostBPFunctionLibrary.h :

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

I get loads of errors such as the following. I guess the errors are all pointing to the clash of check definition in "AssertionMacros.h" and any boost version of it, but the question then is how can I fix that and make it work ? Why is there no clear fundamental separation between the two definitions ? I tried to remove the boost version of "check function" as pointed by the first error line but that breaks other code files in boost, I tried to do that to UE4 and the answer is still no. I feel that there is something fundamentally wrong here. Please advice.

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

There are 1 best solutions below

0
On BEST ANSWER

There is an answer - a sort of explanation as to why this is happening in unreal Engine forums for library macro conflicts. There is a dirty work around will try that.