4

Basically, I am asking, whether my code should say

#include “../libs/src/my_lib.h”

or

#include “my_lib.h”

with a complier option of

-I ../libs/src/   

I feel (reasonably strongly) that the former is preferable, because:

  • it is independent of build system
  • it specifies exactly which “my_lib” is meant, in case there are several.

My current project uses the latter style, with -I in the project file, saying that:

  • we will never change build system, compiler or platform
  • every file has a unique name

That actually sounds reasonable, so I wonder if I am just being influenced by opinion, or whether there is any technical reason (not an opinion) to prefer one approach over the other.

Mawg
  • 4,298

1 Answers1

9

In my current workplace, various projects are using boost versions ranging from 1.60 to 1.66, and at appropriate times we move those forward. It's much simpler to repoint the project includes to a different folder and leave all the #includes alone.

These projects are cross platform, we are using multiple compilers. Each compiler has some equivalent of -I ../libs/src/, and we use qmake to coordinate them all.

As amon notes in a comment,

I don't think it's appropriate to view your build system as separate from your project. Your Makefiles (or equivalents) are part of the code.

Caleth
  • 12,190