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"

How can I resolve these compiler errors?

Hi there,

I recently tried using C++ with ue4 again after not doing it for a while, since I had problems last time and never got around to solve those problems. Now, I followed the "Intro to Programming" video to get into the programming part, but when I type exactly the same code(except for the "VisibleAnywhere" parameter), I get a bunch of errors which are unlogical.

Powerup.h:

 #pragma once
 
 #include "GameFramework/Actor.h"
 #include "Powerup.generated.h"
 
 /**
  * 
  */
 UCLASS()
 class APowerup : public AActor
 {
     GENERATED_UCLASS_BODY()
 
     UProperty(VisibleAnywhere, Category = Powerup) 
        TSubjectPtr<USphereComponent> TouchSphere;
 
     UProperty(VisibleAnywhere, Category = Powerup)
         float RotationRate;
 
     virtual void Tick(float DeltaTime) OVERRIDE;
     
 };

Powerup.cpp:

 #include "Pizza.h"
 #include "Powerup.h"
 
 
 APowerup::APowerup(const class FPostConstructInitializeProperties& PCIP)
     : Super(PCIP)
 {
     PrimaryActorTick.bCanEverTick = true;
 
     TouchSphere = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("TouchSphereComponent"));
     TouchSphere->SetSphereRadius(20.0f, false);
     RootComponent = TouchSphere;
 
     RotationRate = 180.0f;
 
 }
 
 void APowerup::Tick(float DeltaTime)
 {
     Super::Tick(DeltaTime);
 
     FRotator MyRot = GetActorRotation();
     MyRot.roll += RotationRate * DeltaTime;
     SetActorRotation(MyRot);
 }
 

And here are the errors:

 Error    1    error C2061: syntax error : identifier 'VisibleAnywhere'    c:\users\mathias\documents\unreal projects\pizza\source\pizza\Powerup.h    16    1    Pizza
 Error    2    error C3646: 'TSubjectPtr' : unknown override specifier    c:\users\mathias\documents\unreal projects\pizza\source\pizza\Powerup.h    16    1    Pizza
 Error    3    error C2143: syntax error : missing ';' before '<'    c:\users\mathias\documents\unreal projects\pizza\source\pizza\Powerup.h    16    1    Pizza
 Error    4    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    c:\users\mathias\documents\unreal projects\pizza\source\pizza\Powerup.h    16    1    Pizza
 Warning    5    warning C4183: 'UProperty': missing return type; assumed to be a member function returning 'int'    c:\users\mathias\documents\unreal projects\pizza\source\pizza\Powerup.h    16    1    Pizza
 Error    6    error C2059: syntax error : '<'    c:\users\mathias\documents\unreal projects\pizza\source\pizza\Powerup.h    16    1    Pizza
 Error    7    error C2238: unexpected token(s) preceding ';'    c:\users\mathias\documents\unreal projects\pizza\source\pizza\Powerup.h    16    1    Pizza
 Error    8    error C2061: syntax error : identifier 'VisibleAnywhere'    c:\users\mathias\documents\unreal projects\pizza\source\pizza\Powerup.h    19    1    Pizza
 Error    9    error C2144: syntax error : 'float' should be preceded by ';'    c:\users\mathias\documents\unreal projects\pizza\source\pizza\Powerup.h    20    1    Pizza
 Error    10    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    c:\users\mathias\documents\unreal projects\pizza\source\pizza\Powerup.h    20    1    Pizza
 Error    11    error C2535: 'int APowerup::UProperty(void)' : member function already defined or declared    c:\users\mathias\documents\unreal projects\pizza\source\pizza\Powerup.h    20    1    Pizza
 Warning    12    warning C4183: 'UProperty': missing return type; assumed to be a member function returning 'int'    c:\users\mathias\documents\unreal projects\pizza\source\pizza\Powerup.h    20    1    Pizza
 Error    13    error C2065: 'TouchSphere' : undeclared identifier    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.cpp    12    1    Pizza
 Error    14    error C2065: 'TouchSphere' : undeclared identifier    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.cpp    13    1    Pizza
 Error    15    error C2227: left of '->SetSphereRadius' must point to class/struct/union/generic type    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.cpp    13    1    Pizza
 Error    16    error C2065: 'TouchSphere' : undeclared identifier    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.cpp    14    1    Pizza
 Error    17    error C2039: 'roll' : is not a member of 'FRotator'    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.cpp    25    1    Pizza
 Error    18    error C2061: syntax error : identifier 'VisibleAnywhere'    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.h    16    1    Pizza
 Error    19    error C3646: 'TSubjectPtr' : unknown override specifier    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.h    16    1    Pizza
 Error    20    error C2143: syntax error : missing ';' before '<'    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.h    16    1    Pizza
 Error    21    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.h    16    1    Pizza
 Warning    22    warning C4183: 'UProperty': missing return type; assumed to be a member function returning 'int'    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.h    16    1    Pizza
 Error    23    error C2059: syntax error : '<'    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.h    16    1    Pizza
 Error    24    error C2238: unexpected token(s) preceding ';'    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.h    16    1    Pizza
 Error    25    error C2061: syntax error : identifier 'VisibleAnywhere'    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.h    19    1    Pizza
 Error    26    error C2144: syntax error : 'float' should be preceded by ';'    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.h    20    1    Pizza
 Error    27    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.h    20    1    Pizza
 Error    28    error C2535: 'int APowerup::UProperty(void)' : member function already defined or declared    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.h    20    1    Pizza
 Warning    29    warning C4183: 'UProperty': missing return type; assumed to be a member function returning 'int'    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Source\Pizza\Powerup.h    20    1    Pizza
 Error    30    error : Failed to produce item: C:\Users\Mathias\Documents\Unreal Projects\Pizza\Binaries\Win64\UE4Editor-Pizza-Win64-Debug.pdb    C:\Users\Mathias\Documents\Unreal Projects\Pizza\Intermediate\ProjectFiles\ERROR    Pizza
 Error    31    error MSB3073: The command "D:\UnrealEngine\Github\UnrealEngine\Engine\Build\BatchFiles\Build.bat PizzaEditor Win64 Debug "C:\Users\Mathias\Documents\Unreal Projects\Pizza\Pizza.uproject"" exited with code -1.    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets    38    5    Pizza
 

 






Product Version: Not Selected
Tags:
more ▼

asked May 19 '14 at 05:11 PM in C++ Programming

avatar image

maroen
26 4 5 6

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

1 answer: sort voted first

Hi maroen,

One thing that I noticed is that you used UProperty instead of UPROPERTY in your header. Try changing the two lines with

 UProperty(VisibleAnywhere, Category = Powerup)

to

 UPROPERTY(VisibleAnywhere, Category = Powerup

Please let us know if that helps to resolve the compile errors that you received.

more ▼

answered May 19 '14 at 05:56 PM

avatar image

Tim C ♦♦ STAFF
18.4k 422 63 284

avatar image maroen May 19 '14 at 06:15 PM

Thanks!!

That actually solved all the problems, except for it's "MyRot.Roll", not ".roll", and I mistyped TSubobjectPtr once. Now the code finally compiles with no errors! :)

(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