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"

GetLifetimeReplicatedProps in comment causes compile error

If I add

// GetLifetimeReplicatedProps

to header file of any class that implements this function in .cpp file I get compilation error. It looks like override for GetLifetimeReplicatedProps doesn't get declared in GENERATED_BODY.

Product Version: UE 4.8
Tags:
more ▼

asked Aug 10 '15 at 11:02 PM in Bug Reports

avatar image

Demiu
40 4 7 12

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

I know that this thread is pretty old, but OP is absolutely correct. If you have the function "GetLifetimeReplicatedProps" in your header file as a comment, such as //GetLifetimeReplicatedProps, you will be given the error 'GetLifetimeReplicatedProps' : member function not declared in 'AClass'. Most likely a bug.

more ▼

answered Jan 10 '19 at 11:47 PM

avatar image

FezTheImmigrant
6

avatar image Demiu 5 days ago

Feels great being validated after 3 years

(comments are locked)
10|2000 characters needed characters left

Hey Demiu-

Using a function in the source file who's declaration is commented out in the header file will cause compile errors since the compiler doesn't know where the declaration of the function is. Additionally, after looking at the function declaration inside Actor.h, that function is not declared virtual so it cannot be overridden in the child class. If you are using a source built version of the engine then this can be edited in the source code, otherwise you will only be able to call the function from your class without changing its functionality.

Cheers

Doug Wilson

more ▼

answered Aug 11 '15 at 07:05 PM

avatar image Demiu Aug 11 '15 at 10:04 PM

I don't think that I've written original question precisely enough so I'll post some example code.

TestActor.h

 #pragma once
 
 #include "GameFramework/Actor.h"
 #include "TestActor.generated.h"
 
 UCLASS()
 class TESTPROJECT_API ATestActor : public AActor
 {
     GENERATED_BODY()
     
 public:    
     // Sets default values for this actor's properties
     ATestActor();
 
     // Something Something GetLifetimeReplicatedProps, this is not a commented out function declaration
     // The above comment stops file from compiling, if the "GetLifetimeReplicatedProps" string is removed (or broken with space/underscore etc.)from this and the above comment the file can now compile
 
     UPROPERTY(Replicated)
     int32 MyReplicatedInt;
 };
 

TestActor.cpp

 #include "TestProject.h"
 #include "TestActor.h"
 #include "UnrealNetwork.h"
 
 // Sets default values
 ATestActor::ATestActor()
 {
      // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;
 
     SetReplicates(true);
     bAlwaysRelevant = true;
 }
 
 // Implementation of replication function, since i want to have more control over what's getting replicated to who
 void ATestActor::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
 {
     DOREPLIFETIME(ATestActor, MyReplicatedInt);
 }

The issue is not with the commenting out function declaration.

avatar image Doug E ♦♦ STAFF Aug 12 '15 at 01:34 PM

Hey Demiu-

Adding //GetLifetimeReplicatedProps to the .h file does not change the outcome of the compile for me. What is the exact error you get when the compile fails?

avatar image Demiu Aug 12 '15 at 02:08 PM
 'GetLifetimeReplicatedProps' : member function not declared in 'ATestActor'

Error does disappear 100% of the time when a space is added somewhere in GetLifetimeReplicatedProps in comment. I'm using VS Express 2013 with binary 4.8.3 engine version.

avatar image Doug E ♦♦ STAFF Aug 12 '15 at 02:11 PM

That specific error is because the compile see the function in your .cpp file but doesn't know what to do with it since it was not declared in the source file. Adding the function declaration should solve the error

avatar image Demiu Aug 12 '15 at 02:22 PM

I know, it's just that without "GetLifetimeReplicatedProps" somewhere in the comment in the .h file the declaration is done automatically, probably in GENERATED_BODY() macro. The problem is that comment changes compile outcome.

(comments are locked)
10|2000 characters needed characters left
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