UCLASS() throws weird errors. Can't #include.
I am having a major issue with UCLASS macro and the "something.generated.h" files. I've read around 10 posts (couldn't find more) with people who have the same issue but neither post helped me with my problem.
The issue is: UCLASS() throws weird errors when adding anything above itself.
I am not:
1) Including anything between the "something.generated.h" files and the UCLASS macro.
2) Messing with anything inside the code other than adding whitespaces or #include at the top.
I'll be trying to explain this through images, so you can clearly see the code.
Here I have no errors, I have some weird spacing at the top as you can see (no spaces between Copyright, pragma once, first #include) because that would put UCLASS outside of the 10th line, and give an error.
Here it is:
The only change I have made in the entire code is adding a line between #pragma once and #include "CoreMinimal.h" If I make a build here, it succeeds. But it makes me unable to code anything else because almost every line in the .cpp file has an error mark now, saying UGrabber is not a class. Because of that the IntelliSense isn't helping me anymore.
It seems like the UCLASS macro picks itself a line to be on. In this example, it is the 10th line. Putting it anywhere except the 10th line resolves in an error.
A couple projects ago, this was the 11th line. Putting it anywhere else gave me the exact same error.
1) Changing the solution configurations between Development and Development Editor (suggested in another post).
2) Building, Rebuilding, Cleaning and Building, Restarting, Refreshing the VS Project from UE Editor
And that was it. Not many suggestions have come up. I need urgent help on this.
EDIT: The UCLASS error which let me compile before doesn't let me compile now and gives these errors.
The red error marks were always there, but in the 2nd picture I could compile. Now I can't. This just seems to be random.
You will need to compile in order to update the .generated.h, which will contain references to the UCLASS, GENERATED_BODY etc. line numbers in your header. Once UnrealHeaderTool runs, it should produce a new .generated.h with the line numbers updated.
After that, if IntelliSense still gives you still get red squiggles, then this is an IntelliSense problem. You might have to wait until IntelliSense picks up the changes, or force a refresh.
If you get compile errors, this is a different issue and we would need to look at that as a separate concern.
answered Jul 18 '17 at 01:17 PM
Steve Robb STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here