UE4 defines

There are many many defines of UE4 like FORCEINLINE.
I have seen that if I use inline instead of FORCEINLINE the code still works.
This is only one examples but most of the defines of UE4 are useless. So why should I use them and no the original C++ syntex?

For starters, inline is not the same as the FORCEINLINE macro. Inline is a standard C++ keyword which the compiler may choose to disregard if inlining a function wouldn’t actually be a gain. FORCEINLINE is a nonstandard macro which forces the compiler to inline a function anyway. Different compilers will have different keywords (MSVC uses __forceinline, gcc and clang use attribute((always_inline)) but treat it slightly differently) and UE4 is a cross-platform engine, which is why it provides these macros.

If you want your code to compile on all platforms as simply as possible, you should use UE4’s idioms.


1 Like

Thank you :).

Dammit Camille why aren’t you writing a book already…

Writing books (and tutorials) takes time, at least by splitting that across dozens of forums posts, I can pretend I spent less compilation time doing it. :slight_smile: