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

Compile Error In visual studio 2017 #919

Open
runner66 opened this issue Mar 25, 2022 · 7 comments
Open

Compile Error In visual studio 2017 #919

runner66 opened this issue Mar 25, 2022 · 7 comments

Comments

@runner66
Copy link

as document said "It requires C++14 and the Boost Libraries 1.67.0 or later.", but when comiple in VS (with boost1.68+cpp14), I get serveal errors.
boost_1_68_0\boost\variant\detail\make_variant_list.hpp(40): error C2977: “boost::mpl::list”:
boost_1_68_0\boost\variant\detail\make_variant_list.hpp(40): error C2955: “boost::mpl::list”:

Only when I define MQTT_STD_VARIANT with cpp17, I can compile sucess.

@redboltz
Copy link
Owner

On clang++ (13.0.1) -std=c++14, Boost 1.78.0, MQTT_STD_VARIANT=OFF cmake option (MQTT_STD_VARIANT preprocessor macro is not defined), no errors are reported.
C2977 means too many template arguments.

// Use boost variant
// user intentionally defined BOOST_MPL_LIMIT_LIST_SIZE but size is too small
// NOTE: if BOOST_MPL_LIMIT_LIST_SIZE is not defined, the value is evaluate as 0.
#if defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) && BOOST_MPL_LIMIT_LIST_SIZE < 40
#error BOOST_MPL_LIMIT_LIST_SIZE need to greator or equal to 40
#else // defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) && BOOST_MPL_LIMIT_LIST_SIZE < 40
// user doesn't define BOOST_MPL_LIMIT_LIST_SIZE intentionally
// but the defult value could be defined
#undef BOOST_MPL_LIMIT_LIST_SIZE
#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
#define BOOST_MPL_LIMIT_LIST_SIZE 40
#endif // defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) && BOOST_MPL_LIMIT_LIST_SIZE < 40

mqtt_cpp set to the limit list size to 40 if it is not defined.

Those information might help you to analyze the problem.

@redboltz
Copy link
Owner

redboltz commented Mar 25, 2022

Perhaps, insert

#include <mqtt/variant.hpp>

into the top of your source code (cpp file) might solve the error.

If it is solved please let me know the current include information.

@runner66
Copy link
Author

Yes, It works. ths
a little weird...

@runner66
Copy link
Author

another puzzle, what's the difference mqtt_cpp-12.0.0 and mqtt_cpp-master?
seems code is not absolutly the same

@redboltz
Copy link
Owner

redboltz commented Mar 25, 2022

Yes, It works. ths a little weird...

Oh really, I need your source code (mqtt_cpp include part) to fix the issue. So far, I only know the error code. I cant't fix it.

Maybe

#include <mqtt/variant.hpp> // should be top to configure variant limit

#include <mqtt/config.hpp> // should be top to configure boost::variant limit

are related.

@redboltz
Copy link
Owner

another puzzle, what's the difference mqtt_cpp-12.0.0 and mqtt_cpp-master? seems code is not absolutly the same

You can compare by yourself
v12.0.0...master

@runner66
Copy link
Author

Ok, ths.
I try to compile the same code in Linux OS with vscode, but get a lot of errors, any tips?

mqtt/will.hpp:47:23: error:enclosing class of constexpr non-static member function ‘mqtt::buffer& mqtt::will::topic()’ is not a literal type
constexpr buffer& topic() {
^
mqtt/will.hpp:50:29: error:enclosing class of constexpr non-static member function ‘const mqtt::buffer& mqtt::will::message() const’ is not a literal type
constexpr buffer const& message() const {
^
mqtt/will.hpp:53:23: error:enclosing class of constexpr non-static member function ‘mqtt::buffer& mqtt::will::message()’ is not a literal type
constexpr buffer& message() {
^
mqtt/will.hpp:56:22: error:enclosing class of constexpr non-static member function ‘mqtt::retain mqtt::will::get_retain() const’ is not a literal type
constexpr retain get_retain() const {
^
mqtt/will.hpp:59:19: error:enclosing class of constexpr non-static member function ‘mqtt::qos mqtt::will::get_qos() const’ is not a literal type
constexpr qos get_qos() const {
^
mqtt/will.hpp:62:37: error:enclosing class of constexpr non-static member function ‘const properties& mqtt::will::props() const’ is not a literal type
constexpr v5::properties const& props() const {
^
mqtt/will.hpp:65:31: error:enclosing class of constexpr non-static member function ‘mqtt::v5::properties& mqtt::will::props()’ is not a literal type
constexpr v5::properties& props() {

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