Download

c++ to blueprint

Hello friends :slight_smile:

I’m programming a plugin for livestreaming mocapdata to unreal. Now I’m trying to make my functions for connection blueprintable.
But I’m always getting some errors and I hope you can help me ? :slight_smile:

here’s the code:

.h file



#pragma once

#include "CoreUObject.h"
#include <Client.h>
#include "ViconConnection.generated.h"

DECLARE_LOG_CATEGORY_EXTERN(LogViconConnection, Log, All);

UCLASS(Blueprintable)
class UViconConnection : public UObject
{
	GENERATED_UCLASS_BODY()
public:
	UFUNCTION(BlueprintCallable, Category = "ViconFunctions")
	void connect(std::string hostaddress);
	UFUNCTION(BlueprintCallable, Category = "ViconFunctions")
	void disconnect();
	std::string hostaddress;
	

private:
	ViconDataStreamSDK::CPP::Client Client;
	//DECLARE_LOG_CATEGORY_EXTERN(Datastream, Log, All);
};


and here are the errors I’m getting:

Error 2 error : In ViconConnection: Unrecognized type ‘std’

Error 3 error code: 2

Thank you for your help :slight_smile:

Uh, i’m not that good at C++, but it’s marking the std of “std::string hostadress”.
Would it fix the error if you use


FString hostadress;

You should ask c++ related stuff in the c++ section. If you want to youse the std lib you should include it. but that FString should solve your problem

Thanks a lot. That helped.

But now the problem I have is, how can i convert a FString back to std::string?

Avoid using standard C++ stuff and system calls, use UE4 API as much as possible, because they are made to be portable and you are sure that your game will run where UE4 is supported without changing code when you use them

I’m not sure if the standard string header is included by default. Does adding a


#include <string> 

help with the original version?