Where can i get the preprocessing source file

The engine and editor use a lots of macros and templete meta function.And it hards to read.
So where should i get start? or how can i get the sources file after preprocessing.
I want to understand how the unreal reflection system work internal.

1 Like

Here’s how I get the preprocessed MyActor.cpp:

Find the Compiler Response File “MyProject/Intermediate/Build/Win64/MyProect/Debug/MyActor.cpp.obj.response”.

Find all Preproscessor Definitions under VS2015 project properties ->NMake.

Edit .response file

  • Insert Preproscessor Definitions into .response file

  • Replace the /Fo line with /P

open “VS2015 x64 Native Tools Command Prompt”

cd MyProject/Intermediate/Build/Win64/MyProect/Debug/

cl.exe @MyActor.cpp.obj.response

Then the huge prepocessed c++ file MyActor.i is generated

Use clang-format to beautify it

Unfortunately, I follow your suggestion but get error:
cl.exe @MyActor.cpp.obj.response
cl : Command line warning D9002 : ignoring unknown option ‘/PF:\TestProject\ReflectionTest\Intermediate\Build\Win64\UE4Editor\Development\ReflectionTest\MyActor.cpp.obj’
MyActor.cpp
F:\TestProject\ReflectionTest\Source\ReflectionTest\MyActor.cpp: fatal error C1853: ‘F:\TestProject\ReflectionTest\Intermediate\Build\Win64\UE4Editor\Development\ReflectionTest\PCH.ReflectionTest.h.pch’ precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa)

Can u give me more details?

Here’s the tail of my .response file
136488-

Still get error:
Insert Preproscessor Definitions:
/D_WINDLL
/DUE_EDITOR=1
/DIS_PROGRAM=0
/DWITH_DEV_AUTOMATION_TESTS=1
/DWITH_PERF_AUTOMATION_TESTS=1
/DUNICODE
/D_UNICODE
/D__UNREAL__

Error Msg:
F:\TestProject\ReflectionTest\Intermediate\Build\Win64\UE4Editor\Development\ReflectionTest>cl.exe @MyActor.cpp.obj.response
MyActor.cpp
c:\program files (x86)\epic games\ue_4.15\engine\source\runtime\core\public\Windows/WIndowsPlatform.h(5): fatal error C1083: Cannot open include file: ‘sal.h’: No such file or directory

Run cl.exe in Visual Studio Developer Command Prompt

The Developer Command Prompt for Visual Studio automatically sets the environment variables

If you’re using WIN10, press [Win] key, then search for “VS2015 x64 Native Tools Command Prompt”

Location in my machine :
“c:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x64 Native Tools Command Prompt”

Work now,Thx a lot!!!
Thanks for your patience!