This line: "using int32 = int;" doesn't seem to be neccessary in FBullCowGame.cpp

I don’t seem to be having any errors relating to this not being in my code.
I rebuilt the project and it runs just fine.

Is what is done in the video overkill or is it future-proofing against potential mistakes?

I figure that because it includes the header file we are fine

It’s like when you use TMap (not sure if you’ve gotten to that part yet), all it’s doing is using types that you’ll usually use in your Unreal code in the future. Both int32 and int are valid types, so that’s why it compiles, though the size of int is implementation-based. Because of this, int32 is usually used in UE4 code to keep things working cross-platform.

EDIT: Can’t figure out strikethrough on here, but what I said was wrong. At this point int is pretty much always the same as int32, but the innards of UE4 use int32, so I’m guessing that’s the reason you’ll want to be acclimated using it.

There are two reasons we are using int32:

  • Unreal uses int32 so that multiple platforms can use the same code. Implementation of this just prepares you for Unreal.

  • It is teaching those who are new about coding structure. Some people don’t know you can reference a variable through different means such as substituting one name for another.

Since the other guys seem to have misunderstood your question, I’ll try to answer it for you. It’s kind of overkill but it does protect you if for whatever reason the header file no longer uses it but since you know the scope of the entire project that shouldn’t happen, so it would be fine to leave it out.

3 Likes

Hi,
I also ran into this question.

Figured that putting using int32 = int; in the header file is enough since all of it’s content will be copied to the FBullCowGame.cpp because of the #include “FBullCowGame.h” command.

This is also why there are no problems with FString in FBullCowGame.cpp even though there’s no using FString = std::string; command there right?

2 Likes

I just ran into this myself - as the .h file is basically a copy paste into its relevant .cpp file, it works because it’s already in there once compiled.

My FBullCowGame.cpp has neither in, and I get a successful build.

I’m not sure what the best practice on this is, yet! Hopefully we’ll get some advice in the course.

Privacy & Terms