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"

[Bug Report] Clang 3.5 compilation error with -Werror and -Wshado

It seems Clang is a little rabid in terms of variable naming - because "-Wshadow" is set, attempting to compile a C++ class on Linux using Clang 3.5 results in a warning when a function parameter has the same name as data member. As the flag "-Werror" is also set, this warning gets promoted to a full-blown error and interrupts the build.

Dropping "-Werror" from the compilation arguments should theoretically make these issues a visual log annoyance instead of a blocking issue. GCC has had the same issue as a bug report, but has apparently fixed it.


The provided sample code below compiles fine on Windows 7 using Visual Studio 2013 Community, but fails with the following error on Linux Mint 17.2, using Qt Creator and Clang 3.5.

Sample code:

 #pragma once
 #include "GameProject.h"
 #include "MemoryElement.generated.h"
 struct GAMEPROJECT_API FMemoryElement
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Memory")
         FString KeyName;
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Memory")
         FString Data;
         KeyName = "";
         Data = "";
     FMemoryElement(FString KeyName, FString Data)
         this->KeyName = KeyName;
             this->Data = Data;

Compilation Error:

 In file included from /home/jarl/Programming/Unreal Projects/GameProject 4.8/Intermediate/Build/Linux/x86_64-unknown-linux-gnu/UE4Editor/Inc/GameProject/GameProject.generated.cpp:9:
 In file included from ../../../Unreal Projects/GameProject 4.8/Intermediate/Build/Linux/x86_64-unknown-linux-gnu/UE4Editor/Inc/GameProject/GameProject.generated.dep.h:21:
 ../../../Unreal Projects/GameProject 4.8/Source/GameProject/Dialogue/MemoryElement.h:27:25: error: declaration shadows a field of 'FMemoryElement' [-Werror,-Wshadow]
         FMemoryElement(FString KeyName, FString Data)
 ../../../Unreal Projects/GameProject 4.8/Source/GameProject/Dialogue/MemoryElement.h:16:11: note: previous declaration is here
                 FString KeyName;
 ../../../Unreal Projects/GameProject 4.8/Source/GameProject/Dialogue/MemoryElement.h:27:42: error: declaration shadows a field of 'FMemoryElement' [-Werror,-Wshadow]
         FMemoryElement(FString KeyName, FString Data)
 ../../../Unreal Projects/GameProject 4.8/Source/GameProject/Dialogue/MemoryElement.h:19:11: note: previous declaration is here
                 FString Data;

While workarounds are available (renaming member variables to have a trailing underscore, renaming the function parameter), it is a common idiom to give function parameters the same name as the variable they initialize or affect.

 Distro: Linux Mint 17.2
 Compiler: Clang 3.5
 IDE: Qt Creator
 Unreal Engine: 4.8.3 (Github 4.8 branch source build)

Product Version: UE 4.8
more ▼

asked Aug 25 '15 at 10:26 AM in Linux

avatar image

808 39 30 65

avatar image Jargon Aug 26 '15 at 06:34 PM
(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
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