I usually use #pragma region and #pragma endregion directives to specify regions in my code to collect methods, class members which belong to a specific category. This makes my huge header and cpp files easier to read.
Today I’ve just noticed a very peculiar thing.
For the first time I put a #pragma region definition inside a struct (defined with USTRUCT). And then I got the following
“Unexpected ‘}’. Did you miss a semi-colon?”
regions inside Classes on the other hand work fine.
When I remove these #pragma directives the code compiles just fine.
It appears that this issue occurs if I have not one but multiple regions inside the struct.
This appears to be a problem with the unreal’s pre build step in which the “*.generated.h” are created.
Seems like the code which reads the USTRUCTS does something strange on #pragma directives and forgets to put a semi-colon in the generated header file somewhere… I am not sure though.
This took like 2-3 hours for me to figure out that this issue occurs because of the #pragma directives.
If I comment out the #pragma directives this struct compiles just fine. With them I get the following error:
“FooStruct.h(26): error : Unexpected ‘}’. Did you miss a semi-colon?”
It appears that having multiple pragma directives is not important. Seems like this occurs when you put a pragma directive around a method. If you cut-paste the same pragma directives above so that they cover only the fooMember then it again compiles just fine.