BlueSpud / ClientPredictionExample

MIT License
0 stars 0 forks source link

Linux Clang Compile Errors #5

Open MountainKing123 opened 3 weeks ago

MountainKing123 commented 3 weeks ago

Greetings, I have encountered some compiler issues with linux/clang builds. To fix those I had to: move FEventIds::kNextEventId declaration to cpp and remove unnecessary typename qualifier from FWrappedState<State> using.

I have those fixes on a local branch, so if you give me permission to push to a remote branch, I will do so.

MountainKing123 commented 3 weeks ago

Hey, sorry, I have to correct the event part above. If you just do what I said, you will get a redefinition compile error, as soon as you use the event type for custom events. I think the proper way to fix this, is to use inline static. So the struct would be:

    struct FEventIds {
        inline static EventId kNextEventId = 0;

        template <typename EventType>
        static EventId GetId() {
            static EventId kEventId = ++kNextEventId;
            return kEventId;
        }
    };

This allows you to init the static member in the struct itself, eliviating the need for a global variable (which is good) and it is still visible in other modules. Anything else, should not work. For example extern is not allowed on data members either. C++ static is fun..

Anyway, please correct me if you think I'm wrong.