-1

I am trying to use the EASTL for a project I'm working on, it wouldn't compile and the only error I could find came from its "EASTL/initializer_list.h", I am working with the newest version of this file. The 2 errors that came were C2953 and another one telling me to look at its definition. The EASTL automatically disables all warnings that came along with including this file and even has its own definition of it to use in its files. The only problem is this is including the windows version of the file and it's still causing an error, even though it should be including just fine? I am working on C++14, my platform toolset is v142 (Visual Studio 2019), and my Windows SDK version is 10.0; I am aware is says to update the "EA_HAVE_CPP11_INITIALIZER_LIST define from ", which I have already done, so that shouldn't be the issue.

Here is the code causing the error:

#if defined(EA_HAVE_CPP11_INITIALIZER_LIST) // If the compiler can generate calls to std::initializer_list...

// The initializer_list type must be declared in the std namespace, as that's the 
// namespace the compiler uses when generating code to use it.
EA_DISABLE_ALL_VC_WARNINGS()
#include <initializer_list>
EA_RESTORE_ALL_VC_WARNINGS()

#else

// If you get an error here about initializer_list being already defined, then the         EA_HAVE_CPP11_INITIALIZER_LIST define from <EABase/eahave.h> needs to be updated.
namespace std
{
    // See the C++11 Standard, section 18.9.
    template<class E>
    class initializer_list
    {
    public:
        typedef E         value_type;
        typedef const E& reference;
        typedef const E& const_reference;
        typedef size_t    size_type;
        typedef const E* iterator;             // Must be const, as initializer_list (and its mpArray) is an immutable temp object.
        typedef const E* const_iterator;

    private:
        iterator  mpArray;
        size_type mArraySize;

        // This constructor is private, but the C++ compiler has the ability to call it, as per the C++11 Standard.
        initializer_list(const_iterator pArray, size_type arraySize)
            : mpArray(pArray), mArraySize(arraySize) { }

    public:
        initializer_list() EA_NOEXCEPT  // EA_NOEXCEPT requires a recent version of EABase.  
            : mpArray(NULL), mArraySize(0) { }

        size_type      size()  const EA_NOEXCEPT { return mArraySize; }
        const_iterator begin() const EA_NOEXCEPT { return mpArray; }            // Must be const_iterator, as initializer_list (and its mpArray) is an immutable temp object.
        const_iterator end()   const EA_NOEXCEPT { return mpArray + mArraySize; }
    };
}

#endif

I have tried making it use both the std version of the class and the EA version of the class, both of which cause the same error (C2953). Any help is appreciated as I want to be able to compile this sooner rather than later!

James
  • 83
  • 6
  • Did you follow the advice in the "If you get an error here about initializer_list being already defined [...]" comment? – molbdnilo Mar 05 '20 at 15:33
  • I just edited the question, yes I have already done that and it changed nothing, regardless it shouldn't matter as I forced it to use both definitions and is currently using the windows definition, which should compile just fine. – James Mar 05 '20 at 15:34
  • please show how you modified the macro. btw I find it a bit strange that they add something to `std` in the first place, looks like asking for trouble and now you got it – 463035818_is_not_an_ai Mar 05 '20 at 15:34
  • All I did was update the macro definition to the most recent eabase.h file, which can be found here: https://pastebin.com/ZKgFSbSq I keep saying this but I am currently using the Windows STD definition of this class and it still gives this error. Also, they only add their own version of the class to the std namespace when they can't find it, they don't intend on doing it every compile anyways. – James Mar 05 '20 at 15:38
  • How did you update macro definition? How are you forcing it to use the default implementation? (The simplest method would be to change the condition to `#if 1`.) – molbdnilo Mar 05 '20 at 15:44
  • That's exactly what I did? No rush but can we stop talking about the macro and more about the actual issue? – James Mar 05 '20 at 16:26

1 Answers1

0

Figured it out with the help of a friend, it was an include order issue.

The fix was to just put the "EA_HAVE_CPP11_INITIALIZER_LIST" in the Pre-Processing definition list.

James
  • 83
  • 6