1

For my understanding, hpp is the combination of h and cpp. When I looking into source code, I found sometimes hpp is preferred and sometimes h + cpp is preferred. But I don't know the reason. Could you help me to explain it?

yuxuan
  • 417
  • 5
  • 16
  • 3
    "*For my understanding, hpp is the combination of h and cpp*" - your understanding is wrong. Read more [here](https://stackoverflow.com/questions/152555/h-or-hpp-for-your-class-definitions). – Fureeish Feb 21 '19 at 00:33
  • `For my understanding, hpp is the combination of h and cpp.` No. `.hpp` is often used for header files in c++ projects to not confuse them with c header files. – tkausl Feb 21 '19 at 00:34

1 Answers1

0

and sometimes h + cpp is preferred. But I don't know the reason. Could you help me to explain it?

That may depend on how the build system works.

There are cases that you want to expose a c-style API (usually indicated with the .h extension) but have an implementation written in c++ (.cpp).
The build system should be able wich compile mode (plain c or c++) should be used to handle translation units.


In general: Pairing .hpp .hxx, .hh, .h++ with a .cpp translation unit is the right way to make the build system rules happy.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190