This isn’t a question about c++ best practices. Visual Studio has some quarks about searching for includes depending on <> or “”. So I’ve always used <> when the header is external to the existing project (header from a library).
My team leader recently said not to use the <> because it causes problems with the build (packaging), I think something to do with Unreal parsing (not sure).
How this came up is that I’m using WholeTomato (Visual Assist) and when you use the ‘Add Include’ feature it seems to figure out what you need and uses the <> when external to the project. Well, anything in Engine is external to our game so we get a lot of <>.
Now to be crazy I did change all the “” to <> in one of my cpp files and it compiles and runs fine (not building a package).
So is Unreal confused by <>?
The original language intent was that
"" is used for header files that are located right next to the source file that includes them, and
<> is used for header files that live anywhere else, and the
-I command line flag specifies additional directories that are searched for the
Because the world is what it is, and porting between platforms requires compromises, most compilers now also allow specifying additional paths for the
"" formulation, but sometimes, this set of paths is different from the set of paths of
Then there’s the common behavior that
if I can't find it using the "" rules, then I try the <> rules
Given that you’ll need a bunch of different compilers for the different platforms, there’s no single behavior you can rely on, other than the minimal standard of
"" means right next to the including file, and then falling back to the <> paths if not found."
So, that being said, for Unreal, I use
If it lives in the same module/plugin, I use "", else I use <> and that seems to work for me. I believe it actually ends up falling back to the
<> behavior for things the it picks up from
Public/ or whatever, but that seems to be invisible, and seems to work OK.
Thanks. I believe you’re saying that you have never had a problem using #include <>. Do you target multiple platforms? My team leader has a broad background in Unreal development, but he brings a lot of quirks to the table too. Being an old-time VS/Windows developer myself, some of what he says makes me scratch my head. Like using AActor* TheActor; instead of AActor *TheActor, because it confuses programmers into thinking you are dereferencing TheActor. I just smile at that one.
For any file in a different module, project, or plugin, the
<> includes should not only work, but be preferred. Never had a problem. Then again, I’ve only built Unreal projects for Windows and Android, so I’m probably not the widest aperture for source information there.
Anyway – using
"" to include something that is outside your module, should never be necessary, or even be expected to work particularly well. If that changed behavior on some previous project, chances are that something else was actually wrong on that project, and when they jiggled that particular handle, it “worked” so they then cargo-culted that onwards.
Also: East const, right star, everytime!
char const *foo;
Reading right-to-left (as one does in cdecl): Foo is a pointer to a constant character. Anything else is less consistent with the actual way the language parser works.