FLWL / aoe2-ai-module

Library to extend AI scripting capabilities in Age of Empires 2.
GNU Lesser General Public License v2.1
16 stars 6 forks source link

Error in auth_context.h when trying to build #6

Open Overconfidence opened 3 years ago

Overconfidence commented 3 years ago

Hi! Tried to build the code, although I get an error in this line (line 38): class AuthPropertyIterator : public std::iterator<std::input_iterator_tag, const AuthProperty> {

the full error is this: Error C4996 'std::iterator<std::input_iterator_tag,const grpc::AuthProperty,ptrdiff_t,const grpc::AuthProperty *,const grpc::AuthProperty &>': warning STL4015: The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. (The header is NOT deprecated.) The C++ Standard has never required user-defined iterators to derive from std::iterator. To fix this warning, stop deriving from std::iterator and start providing publicly accessible typedefs named iterator_category, value_type, difference_type, pointer, and reference. Note that value_type is required to be non-const, even for constant iterators. You can define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.

Basically I need to define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS in one of the file before I include anything else to make VS ignore the error, however I don't know in which file I should do this, as I tried to define it in multiple files, to no avail. PS: I use Visual Studio 2019

FLWL commented 3 years ago

Hi, this is due to the gRPC dependancy which does not fully support C++17 as its implemented in VS 2019 (see https://stackoverflow.com/questions/59939678/grpc-auth-context-h-using-stditerator-produces-deprecated-warning-with-latest).

The main branch of this repo was compiled with VS 2017. The dev branch (https://github.com/FLWL/aoe2-ai-module/tree/dev) has been since upgraded to VS 2019 and in fact has _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING enabled under VS C++ preprocessor defintions which fixes this issue. The code in the dev branch should be in working order. I haven't pushed changes to the main repository yet as most of them are technical and there isn't much new functionality.