Closed Ryan-rsm-McKenzie closed 2 years ago
I was just writing a similar issue when I noticed yours before submitting mine. Talk about timing!
Basically in my code, I need to check if an actor has the keyword NPC. Using this code,
auto dobj = RE::BGSDefaultObjectManager::GetSingleton();
auto keywordNPC = dobj->GetObject<RE::BGSKeyword>(RE::DefaultObjectID::kKeywordNPC);
if (actor->HasKeyword(keywordNPC)) {
...
}
I get class "RE::BGSDefaultObjectManager" has no member "GetObjectW"
. Precisely because Windows.h
is overriding it.
In the PCH.h file, the order of the includes has to be like this:
#include "RE/Skyrim.h"
#include "SKSE/SKSE.h"
I tried adding #undef GetObject
, but while the code does compile, I get a CTD ingame when the line auto keywordNPC = dobj->GetObject<RE::BGSKeyword>(RE::DefaultObjectID::kKeywordNPC);
is executed.
I'm not sure if the CTD problem is related to this issue of Windows.h
, but I can't think of a workaround for what I'm trying to do.
Resolved in 025ee60.
Why do you include
<Windows.h>
in a public header here? I don't see what's blocking you from putting this into a source file instead. https://github.com/CharmedBaryon/CommonLibSSE-NG/blob/7bc34b175c33b4c96006967e683114fd69f0365b/include/SKSE/Interfaces.h#L12SKSE/Interfaces.h
is intended to be included throughout a developer's entire project, which meansWindows.h
will also be included throughout the entire project, and it is well known to not play nice with other libraries.