Implementation:CARLA simulator Carla Enable UE4 Macros
| Knowledge Sources | |
|---|---|
| Domains | Build System, Unreal Engine Integration |
| Last Updated | 2026-02-15 05:00 GMT |
Overview
enable-ue4-macros.h is a utility header that restores previously saved Unreal Engine 4/5 preprocessor macros after third-party code has been included, reversing the effects of disable-ue4-macros.h.
Description
This header (~2259 lines) is the counterpart to disable-ue4-macros.h. It restores all UE macros that were previously pushed and undefined by using #pragma pop_macro for each macro. It also restores compiler warning states via #pragma warning(pop) for MSVC and #pragma clang diagnostic pop for Clang. Special handling is included for MSVC where UpdateResource is undefined if it was defined (to avoid Windows API conflicts). The macros restored include hundreds of UE-specific identifiers such as IMAGE_BRUSH, BOX_BRUSH, SAFE_RELEASE, CHECK_HR, METAL_FATAL_ERROR, audio mixer macros, AR delegate macros, and many others.
Usage
Always include this header after disable-ue4-macros.h to restore the UE macro environment. These two headers must always be used as a matched pair.
Code Reference
Source Location
- Repository: CARLA
- File:
LibCarla/source/util/enable-ue4-macros.h
Signature
// Restore compiler warning states
#if defined(_MSC_VER)
# pragma warning(pop)
# ifdef UpdateResource
# undef UpdateResource
# endif
#endif
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
// Restore all UE macros:
#pragma pop_macro("GET_AI_CONFIG_VAR")
#pragma pop_macro("BT_VLOG")
#pragma pop_macro("BT_SEARCHLOG")
// ... (hundreds more macro pop calls)
#pragma pop_macro("SAFE_RELEASE")
#pragma pop_macro("CHECK_HR")
// ...
Import
#include <util/disable-ue4-macros.h>
// ... non-UE headers ...
#include <util/enable-ue4-macros.h>
I/O Contract
| Action | Effect | Scope |
|---|---|---|
| Include this header | Restores all UE macros via pop_macro; restores compiler warning states | Reverses disable-ue4-macros.h scope |
| MSVC UpdateResource | Explicitly undefined to prevent Windows API conflict | MSVC builds only |
Usage Examples
// Typical pattern in CARLA RPC headers:
#ifdef LIBCARLA_INCLUDED_FROM_UE4
#include <util/enable-ue4-macros.h>
#include "Carla/Settings/EpisodeSettings.h" // UE4 header
#include <util/disable-ue4-macros.h>
#endif