Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Calling Template Function vs Unrecognized Symbol
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

matahari
New Member

6 Posts

Posted - Sep 28 2018 :  11:57:27 AM  Show Profile  Reply with Quote
Hi,

I have a very simple C++ function template defined in the header file.

template<class T>
T* TestCreateWidget()
{
   return CreateWidget<T>(this);
}


When I call this function in my .cpp file, function name is underlined in red.

UUserWidget* pUW = TestCreateWidget<UUserWidget>();


I can perfectly compile and run the code, and IntelliSense is totally disabled. Any suggestions for the false positive "unrecognized symbol" error?

Kind Regards,

Edited by - matahari on Sep 28 2018 12:01:49 PM

feline
Whole Tomato Software

United Kingdom
16714 Posts

Posted - Sep 28 2018 :  3:08:14 PM  Show Profile  Reply with Quote
Is the function call "TestCreateWidget" being coloured as a function in your cpp file? Is it being coloured correctly in the .h file? The code seems simple enough, nothing here to obviously confuse VA.

If you place the caret into the "TestCreateWidget" function call in the cpp file and press Alt-G, what happens?

As a quick check to make sure the underlining is coming from VA, can you please change the colour set to:

VA Options -> Underlining -> Underline unrecognized symbols using

to something other than Red, something that is still quite distinct. Does the underlining change colour, showing it is from VA, or does it remain Red?

zen is the art of being at one with the two'ness
Go to Top of Page

matahari
New Member

6 Posts

Posted - Sep 28 2018 :  3:57:11 PM  Show Profile  Reply with Quote
Dear feline,

Thanks for your fast reply!
quote:
Originally posted by feline

Is the function call "TestCreateWidget" being coloured as a function in your cpp file? Is it being coloured correctly in the .h file? The code seems simple enough, nothing here to obviously confuse VA.


Yes, "TestCreateWidget" is properly coloured as a function in both .h and .cpp files.
quote:
Originally posted by feline
If you place the caret into the "TestCreateWidget" function call in the cpp file and press Alt-G, what happens?


Well, in that case the caret perfectly jumps to "TestCreateWidget" function template definition in the .h file.
quote:
Originally posted by feline
As a quick check to make sure the underlining is coming from VA, can you please change the colour set to:

VA Options -> Underlining -> Underline unrecognized symbols using

to something other than Red, something that is still quite distinct. Does the underlining change colour, showing it is from VA, or does it remain Red?


I changed it to Green. And yes, it is now underlined with green. Since IntelliSense is disabled, quite sure it is from VA.

Kind Regards,
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
16714 Posts

Posted - Sep 29 2018 :  08:52:31 AM  Show Profile  Reply with Quote
So far I still cannot reproduce this here, but I am setting up a better test, to make sure.

Can you please try running Find References on "TestCreateWidget", from either place, and see what happens? Specifically, in the Find References Results window, is the underlined call shown with a question mark icon? This would show that VA recognises the name of the function call, but cannot properly parse it in this location.

My current guess is that there is something further up the file that is causing this problem. If so, there should be some clues, perhaps in VA Outline or the Alt-M list, where the results shown don't quite match the file.

zen is the art of being at one with the two'ness
Go to Top of Page

matahari
New Member

6 Posts

Posted - Sep 30 2018 :  10:22:55 AM  Show Profile  Reply with Quote
Dear feline,
quote:
Originally posted by feline
Can you please try running Find References on "TestCreateWidget", from either place, and see what happens? Specifically, in the Find References Results window, is the underlined call shown with a question mark icon? This would show that VA recognises the name of the function call, but cannot properly parse it in this location.


Running "Find References" on,

- .cpp file gives me "Find References is not available because the symbol is unrecognized" error message.

- .h file gives me 2 results; the first one (with a small box icon) in the header file, and the second one (with a question mark) in the .cpp file.

quote:
Originally posted by feline
So far I still cannot reproduce this here, but I am setting up a better test, to make sure.


In order to reproduce the issue, would you please try following the steps below?

- Launch Unreal Engine v4.20.3
- Click "New Project".
- Choose "C++ First Person" template, name it "TestProject", and click "Create Project".
- When the project is created, switch to Visual Studio.
- Open either "TestProjectCharacter.cpp" or "TestProjectProjectile.cpp" file.

In both files, all calls to "CreateDefaultSubobject" function are underlined. On mouse hover to any of these calls, VA displays "Unrecognized symbol" error, and the "CreateDefaultSubobject" is a template function for sure.

Below, you may find two screenshots related to the issue.

Kind Regards,





Edited by - matahari on Sep 30 2018 12:02:49 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
16714 Posts

Posted - Oct 01 2018 :  08:50:10 AM  Show Profile  Reply with Quote
I am seeing the same problem here. I was not testing with Unreal. Unreal Engine is doing some clever things, and changes some of the rules. While I look into this, you may be interested in trying out some Unreal helper code I have worked out. It is still in testing, but is looking good.

To do so please close all instances of the IDE, and then in the root directory of your main Unreal Engine project (or projects if you have more than one), in the same directory as the .SLN file, create a new text file called "va_stdafx.h"

Now open the file in a text editor and paste in the following code, making sure the file ends with a blank line:

// va_stdafx.h Feline Unreal Engine fixes
// Version 2.2
// fixed dot converted to -> on iterator over TMap of pointer type

// helps ranged for loop iterate across TMap
template<class KeyType, class ValueType>
class TTuple
{
public:
	KeyType Key;
	ValueType Value;
};

// so that for ranged-loop works correctly when TTuple key is a pointer
// the iterator is still returning the TTuple, not the pointer key
template<typename ContainerType, typename ElementType, typename IndexType>
class TIndexedContainerIterator
{
	ElementType operator* () const;
};

template<class ElementType, class _A>
class TArray
{
public:
	// iterator movement
	typedef TIndexedContainerIterator<ElementType, ElementType> iterator;
	typedef TIndexedContainerIterator<ElementType, ElementType> const_iterator;
	typedef TIndexedContainerIterator<ElementType, ElementType> reverse_iterator;
	typedef TIndexedContainerIterator<ElementType, ElementType> const_reverse_iterator;

	// iterator access
	iterator begin();
	iterator end();
	const_iterator cbegin() const;
	const_iterator cend() const;
	reverse_iterator rbegin();
	reverse_iterator rend();
	const_reverse_iterator crbegin() const;
	const_reverse_iterator crend() const;
  
public:
	// data access
	ElementType& operator[](int32 Index);
};

template<class ElementType, class _A>
class TArrayView
{
public:
	// iterator movement
	typedef TIndexedContainerIterator<ElementType, ElementType> iterator;
	iterator begin();
	iterator end();
};

template<class ElementType, class _A>
class TChunkedArray
{
public:
	// iterator movement
	typedef TIndexedContainerIterator<ElementType, ElementType> iterator;
	iterator begin();
	iterator end();
};

template <class ElementType>
class TDoubleLinkedList
{
public:
	// iterator movement
	typedef TIndexedContainerIterator<ElementType, ElementType> iterator;
	iterator begin();
	iterator end();
};

template<typename ElementType, typename Allocator>
class TIndirectArray
{
public:
	// iterator movement
	typedef TIndexedContainerIterator<ElementType, ElementType> iterator;
	iterator begin();
	iterator end();

public:
	// data access
	ElementType& operator[](int32 Index);
};

template<typename ElementType>
class TLinkedList
{
public:
	// iterator movement
	typedef TIndexedContainerIterator<ElementType, ElementType> iterator;
	iterator begin();
	iterator end();
};

template<class KeyType, class ValueType, class _A, class _S>
class TMap
{
public:
	// required since the member TIterator class has a different pair API
	// uses functions not exposed members, unlike the STL style iterator below
	// BUT also overloads -> to access Key and Value as members
	template<class KeyType, class ValueType>
	class TIterator
	{
		KeyType Key();
		ValueType Value();
		TTuple<KeyType, ValueType> operator->() const;
	}
	TMap::TIterator<KeyType, ValueType> CreateIterator();
	TMap::TIterator<KeyType, ValueType> CreateConstIterator() const;
	TMap::TIterator<KeyType, ValueType> CreateKeyIterator(KeyType InKey);
	TMap::TIterator<KeyType, ValueType> CreateConstKeyIterator(KeyType InKey) const;

public:
	// STL style iterator movement - ranged for loop
	typedef TBaseIterator<TTuple<KeyType, ValueType> > iterator;
	iterator begin();
	iterator end();
};

template<typename ElementType, typename KeyFuncs, typename Allocator>
class TSet
{
public:
	// iterator movement
	typedef TIndexedContainerIterator<ElementType, ElementType> iterator;
	iterator begin();
	iterator end();
};

template<class KeyType, class ValueType, class _A, class _S>
class TSortedMap
{
public:
	// required since the member TIterator class has a different pair API
	// uses functions not exposed members, unlike the STL style iterator below
	template<class KeyType, class ValueType>
	class TIterator
	{
		KeyType Key();
		ValueType Value();
		void RemoveCurrent();
	}
	TSortedMap::TIterator<KeyType, ValueType> CreateIterator();
	TSortedMap::TIterator<KeyType, ValueType> CreateConstIterator() const;
	TSortedMap::TIterator<KeyType, ValueType> CreateKeyIterator(KeyType InKey);
	TSortedMap::TIterator<KeyType, ValueType> CreateConstKeyIterator(KeyType InKey) const;

public:
	// STL style iterator movement - ranged for loop
	typedef TIndexedContainerIterator<TTuple<KeyType, ValueType>, TTuple<KeyType, ValueType> > iterator;
	iterator begin();
	iterator end();
};


With this file saved open the IDE and press the button:

VA Options -> Performance -> Rebuild symbol databases

and restart the IDE and load your main solution. The rebuild will take a few minutes, hopefully not to many. Once this is done you should find VA is more helpful in Unreal code, at least with the classes the helper code is for. I would be interested in any problems you run into with this helper code, plus any other code that VA is still struggling with.

Do you have VA syntax highlighting set to highlight function calls as white? It makes sense on a dark background, it's just not what I am expecting, so feels a bit odd.

zen is the art of being at one with the two'ness
Go to Top of Page

matahari
New Member

6 Posts

Posted - Oct 01 2018 :  10:36:45 AM  Show Profile  Reply with Quote
Dear feline,
quote:
Originally posted by feline
I am seeing the same problem here.


I am glad to hear that you can reproduce the issue.
quote:
Originally posted by feline
While I look into this, you may be interested in trying out some Unreal helper code I have worked out. It is still in testing, but is looking good.


Oh, I am afraid I cannot do that. Please allow me to start telling you the reason for that, by simply quoting from you.
quote:
Originally posted by feline
Unreal Engine is doing some clever things, and changes some of the rules.


Exactly! UE4 is evolving, and Epic Team keeps on changing rules all the time. I have to deal with enough (most of the time, even more than enough) problems, thanks to never-ending issues introduced with each and every UE4 update. Now, if I add your file to my ongoing projects, it means that I will be adding an another layer of "dependency". Then, with each update, I will have to cope with UE4 changes, plus your Unreal helper code. (I believe, keeping the Unreal helper code always up to date will bring an extra workload for you as well.)

So, with all my respect to your kind Unreal helper code efforts, I think Visual Assist should be able to handle UE4 C++ code parsing properly without any tweaks.

Kind Regards,
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
16714 Posts

Posted - Oct 01 2018 :  11:20:57 AM  Show Profile  Reply with Quote
We are working to get to the point where VA can handle UE code without any help, but its not always a quick and simple process. But thank you for your thoughtful answers regardless, it is good to be aware of these points going in.

zen is the art of being at one with the two'ness
Go to Top of Page

matahari
New Member

6 Posts

Posted - Oct 01 2018 :  1:24:06 PM  Show Profile  Reply with Quote
Thanks for your kind reply, feline.

Visual Assist has a great reputation among Unreal C++ community. Your efforts towards proper UE4 code handling is always appreciated.

I just thought you'd like to know that, I have disabled "Underline unrecognized symbol" feature in Visual Assist, due to distractive false positive "unrecognized symbol" issue confirmed above. It seems that, I won't be able to use that feature until it is fixed. Looking forward to hearing from you, soon.

Thanks again for the kind support!

Edited by - matahari on Oct 01 2018 2:24:06 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
16714 Posts

Posted - Oct 02 2018 :  06:20:19 AM  Show Profile  Reply with Quote
I can see the problem here, but so far I have not been able to produce a simple test case that triggers the problem. VA seems to understand what is going on, but I do wonder if the problem is related to overloading the function only on the number of template parameters. I don't recall ever seeing this sort of overloading done before, but it does make sense when you see it. It's just not enough on its own to trigger the underlining.

zen is the art of being at one with the two'ness
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
16714 Posts

Posted - Oct 06 2018 :  3:28:56 PM  Show Profile  Reply with Quote
I have pinned down a pattern, I can sort of see what is going wrong here. It looks like VA does not realize these template functions are actually members of the class, which is why they are being underlined as mistyped symbols. But VA is sort of aware of these functions.

I have put in a bug report for this:

case=119849

zen is the art of being at one with the two'ness
Go to Top of Page

yournamehasbeentaken
New Member

USA
5 Posts

Posted - Nov 17 2019 :  5:54:18 PM  Show Profile  Reply with Quote
Has there been any update to fixing this?

Do it the hard way
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
16714 Posts

Posted - Nov 18 2019 :  2:05:15 PM  Show Profile  Reply with Quote
Which version of VA are you using, and which version of Unreal Engine are you working with?

Some fixes for VA getting confused with Unreal Engine code have been shipped in VA, but we have not resolved all of the problems described in this thread yet.

zen is the art of being at one with the two'ness
Go to Top of Page

yournamehasbeentaken
New Member

USA
5 Posts

Posted - Nov 18 2019 :  6:59:41 PM  Show Profile  Reply with Quote
Hi I'm currently running UE4 4.23 and latest release of VA

Do it the hard way
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
16714 Posts

Posted - Nov 19 2019 :  11:42:12 AM  Show Profile  Reply with Quote
Can you explain exactly what problem you are seeing currently? Using the test code from the first post in this thread, I am not seeing VA underline the template function, using VS2017, VA 2353.0. I am testing with Unreal Engine 4.22.3

I have disabled IDE intellisense, to make sure that underlining of mistyped symbols is coming from VA, and actually unknown symbols are being underlined by VA.

So it looks like the general problem here is not so bad with the current version of VA. So I am wondering what problem you are seeing.

zen is the art of being at one with the two'ness
Go to Top of Page

yournamehasbeentaken
New Member

USA
5 Posts

Posted - Nov 19 2019 :  5:37:05 PM  Show Profile  Reply with Quote
Ok, I haven't used this test code but the problem I keep seeing is just VA underlining CreateDefaultSubobject in particular, I followed the steps of changing the color to be sure it is VA doing it. It all still compiles just fine so not a deal breaker or anything, just annoying. Other wise I'm loving VA. I'm only trying the trial right now but imagine I'll be getting a package when that runs out as working without it already seems like a terrible idea. Thanks for your time.

Do it the hard way
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
16714 Posts

Posted - Nov 21 2019 :  07:46:28 AM  Show Profile  Reply with Quote
Now I know which function to check, I am seeing the same problem here. However I cannot reproduce the problem using a very simple test case. This might take a bit of digging.

Are there any other functions you have noticed that have the same problem?

zen is the art of being at one with the two'ness
Go to Top of Page

yournamehasbeentaken
New Member

USA
5 Posts

Posted - Nov 21 2019 :  08:05:49 AM  Show Profile  Reply with Quote
I noticed when I peek definition of createDefaultSubobject the squiggles go away after a few seconds only to return after closing the definition, I'm not sure what this means but it's got me curious. Another issue I ran into somewhat similar was when setting up overlap events. I peek definition of OnComponentBeginOverlap, works fine but the next level FComponentBeginOverlapSignature when i try to peek definition I get a warning, "A definition for the symbol 'FComponentBeginOverlapSignature' could not be located." all though I believe that is an unrelated issue and probably due to some settings I may have messed up I mention it in case it's related. I added a simple header file and cpp I'm working with in case it helps.

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "FloorSwitch.generated.h"

UCLASS()
class UDEMULTGAMDEVC_API AFloorSwitch : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AFloorSwitch();

    // Overlap trigger volume
    UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category=FloorSwitch)
    class UBoxComponent* TriggerBox;

    // Switch for character to step on
    UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category=FloorSwitch)
    class UStaticMeshComponent* FloorSwitch;

    // Door to move when floor switch is stepped on
    UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category=FloorSwitch)
    UStaticMeshComponent* Door;

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

    UFUNCTION()
    void OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);

    UFUNCTION()
    void OnOverlapEnd(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
};



// Fill out your copyright notice in the Description page of Project Settings.


#include "FloorSwitch.h"
#include <Components/BoxComponent.h>
#include <Components/StaticMeshComponent.h>

// Sets default values
AFloorSwitch::AFloorSwitch()
{
 	// 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;

    TriggerBox = CreateDefaultSubobject<UBoxComponent>(TEXT("TriggerBox"));
    RootComponent = TriggerBox;

    TriggerBox->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
    TriggerBox->SetCollisionObjectType(ECollisionChannel::ECC_WorldStatic);
    TriggerBox->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
    TriggerBox->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Overlap);

    TriggerBox->SetBoxExtent(FVector(62.f, 62.f, 32.f));

    FloorSwitch = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("FloorSwitch"));
    FloorSwitch->SetupAttachment(GetRootComponent());

    Door = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Door"));
    Door->SetupAttachment(GetRootComponent());

}

// Called when the game starts or when spawned
void AFloorSwitch::BeginPlay()
{
	Super::BeginPlay();
	
    TriggerBox->OnComponentBeginOverlap.AddDynamic(this, &AFloorSwitch::OnOverlapBegin);
    TriggerBox->OnComponentEndOverlap.AddDynamic(this, &AFloorSwitch::OnOverlapEnd);
}

// Called every frame
void AFloorSwitch::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

void AFloorSwitch::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
    UE_LOG(LogTemp, Warning, TEXT("Overlap Begin"));
}

void AFloorSwitch::OnOverlapEnd(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
    UE_LOG(LogTemp, Warning, TEXT("Overlap End"));

}

Do it the hard way

Edited by - yournamehasbeentaken on Nov 21 2019 08:07:27 AM
Go to Top of Page

yournamehasbeentaken
New Member

USA
5 Posts

Posted - Nov 22 2019 :  7:38:44 PM  Show Profile  Reply with Quote
Hi, just an update. I re enabled default intellisense and it immediately resolved both issues. Sorry if I've wasted your time. I was told to disable it and just use Visual Assist but this worked so.... Anyways thanks for your responsiveness.

Do it the hard way
Go to Top of Page

KeyC0de
New Member

Greece
7 Posts

Posted - Jan 30 2020 :  7:37:55 PM  Show Profile  Reply with Quote
@feline I am having the exact same problem as matahari and yournamehasbeentaken. 'CreateDefaultSubobject' is underlined for some reason. I have disabled Intellisense (and oh boy.. VA was x5 times faster!) and using VA only. Back with intellisense this wasn't underlined, but now with VA this single thing is underlined. If I hover over it, it says 'Unrecognized Symbol. ALT + G to jump to a guess, see a list of several or let Intellisense try. I did try your fixes with the va_stdafx.h file and it did not work. So I suppose I'll just disable the underlines as they are distracting, unless you have something else to propose that can fix this. I am using UE4_23, MSVS2017 and I have bought VA.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
16714 Posts

Posted - Jan 31 2020 :  10:12:11 AM  Show Profile  Reply with Quote
Unfortunately there is something odd going on with the "CreateDefaultSubobject" function. Sometimes VA will underline this as a mistyped symbol, but other times it won't:

case=141589

We don't currently have a better work around for this than turning off VA underlining of mistyped symbols for now.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2019 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000