Silly detail (JuceHeader path)


#1

I was wondering why the introjucer always generates

If this works just fine and looks better:

  • Bram

#2

Well, because the first version is always guaranteed to work, but the second one will only work if your build environment has been set-up with a suitable include path.


#3

But… By default the introjucer adds the correct include path.

New project -> save -> change include -> builds fine.

Bram


#4

Maybe it does.

But given the choice between a line of code that always finds the correct target file under all circumstances, or a line of code that relies on some other project setting to be correct, why would anyone choose the latter?


#5

Because it may lead people to believe there’s a spurious include. I know it confused me for a second.


#6

Spurious? I don’t understand why that’d be confusing…?


#7

If you are already adding the correct directory in the include paths (even without the user saying that this include path should be there), why would you then still use a relative include? To me that sounds like a fix in two places where only one is needed.

  • bram

#8

Thanks Bram - yes that’s what I meant by spurious.

Seriously Jules, your code is so neat that I see something like that and I think maybe I’m doing something wrong :slight_smile: In the end I ignored it because everything was obviously working.


#9

IMHO whenever it’s possible to use an explicit path, you should always do so. It’s only when your code includes something external which isn’t in a fixed location that you should rely on the include path to find it.


#10

Sounds like a good maxim for your Coding Standards wiki Jules.