Download

adding vanilla c++ to a UE4 project

I tried to get the logitech sdk running in my ue4 project. I plan to use it to interface with my g27 steering wheel and a project based off of the vehicle template (c++ version). The sdk itself is just a bunch of cpp and .h files, no .lib files or dlls to include.

So, I tried to just add the code to my project like i would normally do in visual studio…copy the sdk source folder to the project, in vis studio, add existing, select the source code etc. I also notice that i can just drop in the code to the project, and it would still be “included” but I’m sure thats more of the ue4 build stuff, not nesc visual studio integrating it to the project. Anyway, once the sdk was in place, the code wouldn’t compile because of the conflicts with “INT” “DWORD” and other windows typedefs. I tried to follow the advice of this ue4 answer:

https://answers.unrealengine.com/questions/27560/trouble-using-windows-includes-with-dword-int.html

and this forum post:

but, no dice. No matter how I ordered the includes, it would not compile. I would either get the “no nested includes allowed” error, or the error that states “the premade header for this project must be first.”

since there are a lot of files in the logitech sdk, I decided to remove that code (once i did, it would build no problem) add my own vanilla c++ code instead, hoping that I can figure it all out with simple code.

So i made a header file:



#ifndef MY_TEST_H_INCLUDED_
#define MY_TEST_H_INCLUDED_

#include "carTest.h" //the name of the project. i also tried having this under the AllowWindowsPlatformTypes...no luck
#include "AllowWindowsPlatformTypes.h"


class testClass
{
	public:
	int x,y;
	int someMethod();
};

 #endif //MY_MAIN_H_INCLUDED_ 
#include "HideWindowsPlatformTypes.h" //i had this up above as the last include as well, no luck


and this class implementation



#include "carTest.h"
#include "AllowWindowsPlatformTypes.h"
#include "testClass.h"


int testClass::someMethod()
{
	return x + y;
}
#include "HideWindowsPlatformTypes.h"


but, I’m still getting the same issues, and my google-fu is failing me. I’m not sure how to fix this, so any help is appreciated.

Thanks

Precompiled headers are used in UE4. So you need to put cartest.h first in the cpp file, but not at all in the .h file. Also move the AllowWindowsPlatformTypes.h after the #include “testClass.h” in the .cpp file.

Thanks for the reply, I followed your advice, and I was able to build the code! :cool:

I then added INT z; to the class definition, so i can try to figure out how to build the logitech code like so:



#ifndef MY_TEST_H_INCLUDED_
#define MY_TEST_H_INCLUDED_

#include "AllowWindowsPlatformTypes.h"
class testClass
{
	public:
	int x,y;
	int someMethod();
	INT z; //NEW!
};
#include "HideWindowsPlatformTypes.h"
 #endif //MY_TEST_H_INCLUDED_ 


then changed someMethod() to look like:



#include "carTest.h"
#include "testClass.h"

int testClass::someMethod()
{
	return x + y + z;
}



and that works! So, hopefully I can use this info to get the logitech code to build. I’ll update this post once i figure it all out.

Thanks again for the help.

[edit]

at first glance, adding the logitech stuff wont be as easy as my test example because some header files include other header files, this creates the “Nesting AllowWindowsPLatformTypes.h is not allowed!” error.
I’ll have to see what i can do. Maybe change the types to normal types, or see if all header files need AllowWindowsPLatformTypes.h to be included.

kablammyman, please keep me informed. I’ve talked to a number of people who were interested in a F27 support. I don’t have one so I haven’t spent any time on it, but when you get it working there are people out there who want it.

One thought. Consider compiling the Logitech code into a library and linking in the library. I found this easier then tryingto get third party code to compile into the engine.

okay, I’ll keep you updated. Also, thanks for the tip. Playing around with the include order hasn’t been helping so far, so I may just try the lib approach.

You’ll find these two articles helpful. I know I did.

since the original question has been answered, I started a new thread for the g27 progress here: