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

mqtt\ssl_options.h(470): error C2062: type 'auto' unexpected #513

Open
ffreality opened this issue Aug 28, 2024 · 7 comments
Open

mqtt\ssl_options.h(470): error C2062: type 'auto' unexpected #513

ffreality opened this issue Aug 28, 2024 · 7 comments

Comments

@ffreality
Copy link

ffreality commented Aug 28, 2024

I built both paho.mqtt c and cpp libraries without problem and integrated them to Unreal Engine 5.
But when I try to open UE5 project, Visual Studio 2022 gives this error.

mqtt\ssl_options.h(470): error C2062: type 'auto' unexpected

auto verify(bool on=true) -> self& {
	opts_.set_verify(on);
	return *this;
}

I am using openssl 1.1.1t and added it to UE5, too.

@fpagliughi
Copy link
Contributor

Seems like a problem with the Visual Studio language server. Is there a way so set what version of C++ is expects? C++11, C++17, etc?

@ffreality
Copy link
Author

Seems like a problem with the Visual Studio language server. Is there a way so set what version of C++ is expects? C++11, C++17, etc?

Unreal Engine 5.4.4 specifically use C++ 20

@fpagliughi
Copy link
Contributor

Sorry, I'm not much of a Windows developer anymore.

The trailing return type is valid C++11 (and beyond) syntax. The library builds fine on the command line when I use CMake and the MSVC CLI tools.

Is it maybe that it's trying to build the library for C++20, and something about that has changed? I've only been testing with C++11, and now C++17 for the upcoming version.

@ffreality
Copy link
Author

Sorry, I'm not much of a Windows developer anymore.

The trailing return type is valid C++11 (and beyond) syntax. The library builds fine on the command line when I use CMake and the MSVC CLI tools.

Is it maybe that it's trying to build the library for C++20, and something about that has changed? I've only been testing with C++11, and now C++17 for the upcoming version.

yes, probably you are right.
I will make a for and try to fix it. Maybe we can publish it as a different branch.
Btw. C library doesn't have this problem.

@fpagliughi
Copy link
Contributor

Yeah, the C compiler isn't putting out breaking changes every 3 years!

Are you compiling with the CMake build, or using your own? (Meaning the CMake should be forcing the compiler to use C++11.. and why don't I see the problem building from the command line).

Also, what version of the library are you using? The latest v1.4.1 release?

@ffreality
Copy link
Author

ffreality commented Aug 28, 2024

Yeah, the C compiler isn't putting out breaking changes every 3 years!

Are you compiling with the CMake build, or using your own? (Meaning the CMake should be forcing the compiler to use C++11.. and why don't I see the problem building from the command line).

Also, what version of the library are you using? The latest v1.4.1 release?

I am using CMake and master version. I don't get any error while building library's itself and I can get mqtt static lib in my install location. Like you said, generated solution uses older version of C++

But after integrating it to Unreal Engine 5 (it uses C++ 20), project give that error and doesn't open.

This is my plugin's third party folder.
https://github.com/FF-Plugins-Active/FF_MQTT/tree/main/Source/FF_MQTT/ThirdParty/paho_cpp/Win64

@fpagliughi
Copy link
Contributor

Sorry I have no experience with Unreal Engine and have no idea what it may be trying to do.

Out of curiosity, I tried compiling as C++20, by updating the main CMake file:

-set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD 20)

It compiled fine, but I only tried it on Linux with g++, since I don't have a Windows machine readily available at the moment. I just wanted to rule out a problem with standard C++ as the standard evolves.

The really crazy thing about the error is that it's not even the first place in that file where it encounters auto as a function return type.
https://github.com/eclipse/paho.mqtt.cpp/blob/3631bce7e0bd74cc11a46410669ccd2e23b6caed/include/mqtt/ssl_options.h#L461-L473

It's in the middle of the builder class where nearly every method uses that same pattern.

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