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"

Can I FORCEINLINE a replicated function?


Is it possible to do FORCEINLINE with a replicated function? It would really save some space in my .cpp file.

Product Version: UE 4.8
more ▼

asked Jun 16 '15 at 06:20 PM in C++ Programming

avatar image

82 24 24 30

avatar image joeGraf STAFF Dec 07 '15 at 08:00 PM

FORCEINLINE is a performance optimization and will increase the size of any translation unit you add it to.

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

3 answers: sort voted first

RPC function must be UFUNCTION, but we don't need define exactly same function, but we implement _Implementation and _Validate instead, which we can make FORCEINLINE. Next code works for me just fine:

 /** Server RPC function */
 UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable, Category = "Category")
 virtual void ServerCallString(const FString& string);
 FORCEINLINE void ServerCallString_Implementation(const FString& string) { ... }
 FORCEINLINE bool ServerCallString_Validate(const FString& string) { return true; }


more ▼

answered Jan 27 '16 at 02:26 PM

avatar image

236 12 5 16

avatar image Wrekk Jan 27 '16 at 03:07 PM

That is actually pretty helpful, thanks!

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

In order for a function to be replicated, it needs to be a UFunction, and in order to be a UFunction, it must not be FORCEINLINE or FORCENOINLINE and a couple of other things


Try using macros or a non-UFunction library

more ▼

answered Dec 07 '15 at 08:11 AM

avatar image

95 14 17 21

avatar image Arty-McLabin Apr 19 '18 at 03:23 PM

i have forceinline ufunctions in my code, which work fine inside C++. (a problem calling them in BP, but they still compile and work. why do you think a ufunction can't be forceinline?)

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

Inline and force inline should cause you build errors as the UClass should fail to be referenced externally. You can have a ufunction that calls the forced inline version

more ▼

answered Apr 19 '18 at 04:00 PM

avatar image

joeGraf STAFF
1.5k 35 12 69

avatar image Arty-McLabin Apr 19 '18 at 04:10 PM

they don't cause build errors however and the next code compiles perfectly:

     void setIsAiming(bool new_val)        {setReplicatedFlagAt(1,new_val);}
avatar image joeGraf STAFF Apr 19 '18 at 04:35 PM

I just had to remove inlined ufunctions from a plugin in 4.20 so this might not work going forward

avatar image Arty-McLabin Apr 19 '18 at 04:44 PM

technically it should be possible to have an inline ufunction though, because even if BP don't know the concept of inline (as it is a interpreted language), ufunctions are still usable in C++ as well, and it doesn't make much sense to uninline a function just to make it supported in BP, am i wrong?

(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