Mysterious lack of compiler error

UNavigationSystem includes the following definition:

UWorld* GetWorld() const override { return GetOuterUWorld(); }

The token GetOuterUWorld appears nowhere else in the source tree… including (as far as I can tell) the auto-generated source. How the heck is that compiling? What does it do?

Hey Sneftel-

GetOuterUWorld() does exist in AISystem.h. Looking at the source code for 4.8.3 it is only line 92 of that file.

Cheers

In my codebase (4.8.1), that line has a definition for GetOuterWorld() (with no U). Also, it’s being called on a UNavigationSystem, while that line defines a function in UAISystem.

Figured it out. An object whose UCLASS declaration includes the attribute Within=Foo will have an auto-generated member function called GetOuterFoo(), which calls GetOuter() and casts the result to Foo*. (This is accomplished by the DECLARE_WITHIN macro in ObjectBase.h.)

1 Like