Hi,
I’m currently working on a project in C++ and i have a compilation error on Unreal header PixelFormat .h:
H:\UE4\4.2\Engine\Source\Runtime/Engine/Public/PixelFormat.h(57): error C2059: syntax error : ‘constant’
I don’t know why, here my code :
(Network .h)
#pragma once
#include "NetPrivatePCH.h"
#include "Engine.h"
#include "Network.generated.h"
#define NET_ERROR(err) (FOutputDevice::Log(FName("Net plugin"), ELogVerbosity::Error, FString(err)))
#define NET_WARN(warn) (FOutputDevice::Log(FName("Net plugin"), ELogVerbosity::Warning, FString(warn)))
UCLASS(ClassGroup=Network, editinlinenew, meta=(BlueprintSpawnableComponent))
class UNetwork : public UActorComponent
{
GENERATED_UCLASS_BODY()
public:
~UNetwork();
UFUNCTION(FriendlyName = "OpenClient", Category = Net)
bool OpenClient(const FString &ip, int32 port);
UFUNCTION(FriendlyName = "OpenServer", Category = Net)
bool OpenServer(int32 port);
UFUNCTION(FriendlyName = "Send", Category = Net)
bool Send(const FString &mess);
private:
WSADATA _wsaData;
SOCKET _socket;
};
(Network.cpp)
#include "NetPrivatePCH.h"
UNetwork::UNetwork(const FPostConstructInitializeProperties &init) : UActorComponent(init)
{
}
UNetwork::~UNetwork()
{
}
std::string FStringToString(const FString &str)
{
std::string rstr = "";
int i;
for (i = 0; i < str.Len(); i++)
rstr += TCHAR_TO_UTF8(str[i]);
return (rstr);
}
bool UNetwork::OpenClient(const FString &ip, int32 port)
{
WSAStartup(MAKEWORD(2,0), &_wsaData);
SOCKADDR_IN sin;
sin.sin_addr.s_addr = inet_addr(FStringToString(ip).c_str());
sin.sin_family = AF_INET;
sin.sin_port = htons(port);
if (sin.sin_addr.s_addr == INADDR_NONE)
{
NET_ERROR("IP resolution failed");
return (false);
}
_socket = socket(AF_INET,SOCK_STREAM, 0);
if (_socket == INVALID_SOCKET || bind(_socket, (SOCKADDR *)&sin, sizeof(sin)) == SOCKET_ERROR)
{
NET_ERROR("Connecting IP failed");
return (false);
}
return (true);
}
bool UNetwork::OpenServer(int32 port)
{
return (false);
}
bool UNetwork::Send(const FString &mess)
{
if (send(_socket, FStringToString(mess).c_str(), mess.Len(), 0) == SOCKET_ERROR)
{
NET_WARN("Send failed");
return (false);
}
return (true);
}
(NetPrivatePCH.h)
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "FNet.h"
#include "ModuleManager.h"
#include "AllowWindowsPlatformTypes.h"
#include <WinSock2.h>
#include <string>
#include "HideWindowsPlatformTypes.h"
#include "Network.h"
// You should place include statements to your module's private header files here. You only need to
// add includes for headers that are used in most of your module's source files though.