#include "Http.h" breaks class

Issue:

Importing Http.h breaks code.

Platform:

Windows 7, VisualStudio 2015, UE4.10.1

Related:

To duplicate:

Create a C++ project in unreal engine 4.10.1

Open [project]Character.h
Add one line:

#include "Http.h"

Error: This class has no storage class or type specifier

Based on the other thread, I tried removing whitespace, inserting (exactly) 7 lines, and switching between “development” and “development editor”

Nothing seems to work.

Suggestions? Help?

Please. Thanks!

Is this a compilation error or an intellisense error? Intellisense often will report false errors if you haven’t compiled at least once to get the .generated.h files created.

Also, did you include “HTTP” to your module Build.cs public or private dependencies, like the example below?

public class Backend : ModuleRules
{
	public Backend(TargetInfo Target)
	{
        MinFilesUsingPrecompiledHeaderOverride = 1;
        bFasterWithoutUnity = true;

        PublicDependencyModuleNames.AddRange(new string[] { 
            "Core", 
            "CoreUObject", 
            "Engine",
			"HTTP",
            "OnlineSubsystem",
        });

        PrivateIncludePaths.AddRange(new string[] {
			"Backend/Private",
		});
	}
}

If you don’t do that, your module won’t have access to the HTTP module’s headers.

Thanks for the response. I’m new to C++

This is intellisense I guess? It underlines UCLASS and class in the editor window with the error in the tooltip.

I did add “HTTP” in the Build.cs. Do I need the other lines as well?

What is the proper workflow to stop the errors? Compiling does not seem to affect anything

Thanks again.

Does your project compile at all? Also, how did you add new class? Did you use the editor’s “create new C++ class” or did you do it directly in Visual Studio?

In UE4.10.1 > Create new C++ project

In Visual Studio 2015 > Open [project]Character.h

Add the one line

Open Build.cs

Add the “HTTP”

Project does not compile or build due to this error.

If possible, could you attach your .h, .cpp and .build.cs file so we can take a look?

Since you said you’re new to C++, did you open the [project].sln file (the solution file) or did you open the .h directly from the source in explorer?

Hey edcolmar-

If you’re adding this to the [project]Character.h file, are you adding the include above or below the .generated.h" line? Unreal Header Tool (UHT) looks for .generated.h as the last include in the list so if you have other includes after this then it will cause compile errors. Moving the include for HTTP above the .generated.h should fix the compile issue if this is the case. If you are still getting a compile error can you post the full output log from Visual Studio?

Cheers

Yep. This is a default class with only one line added. Strangely, just pressing “enter” and “save” breaks the code in the exact same way.

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "PaperCharacter.h"
#include "Http.h"
#include "LEETDEMO2Character.generated.h"

// This class is the default character for LEETDEMO2, and it is responsible for all
// physical interaction between the player and the world.
//
//   The capsule component (inherited from ACharacter) handles collision with the world
//   The CharacterMovementComponent (inherited from ACharacter) handles movement of the collision capsule
//   The Sprite component (inherited from APaperCharacter) handles the visuals

class UTextRenderComponent;

UCLASS(config=Game)
class ALEETDEMO2Character : public APaperCharacter
{
	GENERATED_BODY()
[[[[[[[[  TRUNCATED ]]]]]]]]]
};


// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;

public class LEETDEMO2 : ModuleRules
{
	public LEETDEMO2(TargetInfo Target)
	{
		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "Paper2D", "HTTP" });
	}
}

Update: It does compile, but the Intellisense error does not go away. Is there any way to resolve it?

Thanks for the help and suggestions.

I tracked this one down. For anyone else that sees this freaky behavior, check your ue4 plugins.

Mine was due to having FMOD studio installed. When I disabled FMOD, Visual Studio Behaves correctly.

Another update… It turns out that this behavior still continues, even with FMOD disabled… But I did find a workflow that is annoying but works:

change header file in VS, and add any new #include
save
build
close VS
open ue4 project editor
compile
refresh visual studio project
open visual studio

now the class looks correct in VS

I had this same problem and after 30 minutes of frustration trying to get this to work, I deleted all the code from the header file and then undo which somehow fixed it