[UE4] Intellisense Errors and USTRUCT
The Intellisense feature of Visual Studio, while useful is quite different from the compiler and on occassion produces false positive errors. According to the document about Setting Up Visual Studio for UE4{target=”_blank”}, this can happen for few possible reason
- The IntelliSense compiler (EDG) is more strict than the MSVC compiler.
- Some #defines are setup differently for IntelliSense than when building normally.
- C++ compiled by IntelliSense is always treated as 32-bit.
However, there is also the case where the Intellisense is just plain wrong. USTRUCT() structures are just such a case. You will find that Intellisense complains about definitions with the structures defined as USTRUCT.
This may not be a big deal, except for the fact these fales positives makes it difficult to spot actual errors and I like to see a clean workspace with no errors (not even false positives). Fortunately, there is a workaround. You can include the USTRUCT definitions only if it is not being compiled by Intellisense.
Fortunately, it is just the GENERATED_USTRUCT_BODY() line that is the culprit. To get these errors to go away, instead of that single line, use the following
[code language="cpp"]
#ifndef __INTELLISENSE__ /* Eliminating erroneous Intellisense Squigglies
*/
GENERATED_USTRUCT_BODY()
#endif
[/code]
and that'll make those pesky squiggly lines to disappear and give you a nice clean workspace :-D