x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

UCLASS() throws weird errors. Can't #include.

Hey everyone,

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.

alt text

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:

alt text

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.

I've tried:

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.

alt text alt text

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.

Product Version: UE 4.16
Tags:
noerror1.png (45.8 kB)
error2.png (44.9 kB)
error3.png (58.6 kB)
error4.png (31.2 kB)
more ▼

asked Jul 18 '17 at 10:57 AM in C++ Programming

avatar image

m.duman
3 1 2

avatar image Steve Robb STAFF Jul 18 '17 at 12:16 PM

Hi,

Are you actually experiencing compile errors, or are we just talking about the red squiggles from IntelliSense?

Steve

avatar image m.duman Jul 18 '17 at 01:06 PM

I have had issues with compilation before, but I can't replicate it now. Error was, "name followed by "::" must be a class or namespace name." It gave this error because it doesn't qualify my UGrabber class as a class because of the errors. And even if the compilation succeeds, the red squiggles from IntelliSense become a huge issue if you have them all over the screen ( .cpp file for instance). Because of that, any changes I do, IntelliSense thinks there is an error and not help me with anything.

EDIT: Managed to replicate the error. I will edit the post accordingly.

avatar image WouterDB Sep 13 '17 at 05:08 PM

Hi, I'm having the exact same issue: intellisense puts red squiggles in my code while I can successfully compile. This makes it difficult/annoying to write code because it looks like there are errors, but there actually aren't...

For the moment I will set "Disable Squiggles" on "True" in the Visual Studio Intellisense options. This will no longer show the red lines, but actually I'd like to have those red lines present, but only if they appear correctly. If anyone knows how to fix this, please let me know =]

avatar image WouterDB Sep 13 '17 at 05:57 PM

OK so I found the solution here Changing between "Development Editor"/"Development" and compiling solved the false positive errors for me!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

Steve

more ▼

answered Jul 18 '17 at 01:17 PM

avatar image

Steve Robb STAFF
2.4k 56 21 86

avatar image m.duman Jul 18 '17 at 02:13 PM

Thanks Steve, I hope this won't become an issue later on.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question