Physician
Physician

Reputation: 483

Translation unit when including a source file?

As far as I know, a translation unit consists of a single implementation file .cpp/.c and all its included headers' code. When including a .cpp file inside another .cpp file, or including a .cpp file inside a .h file that is included inside yet another .cpp file, what is the translation units we have here?

Upvotes: 0

Views: 155

Answers (1)

Employed Russian
Employed Russian

Reputation: 213955

When including a .cpp file inside another .cpp file, or including a .cpp file inside a .h file that is included inside yet another .cpp file, what is the translation units we have here?

A translation unit is a single file that is being compiled. Here it's the "outernmost" .cpp file.

That said, #including a .cpp inside .h is a really bad idea™️.

Upvotes: 1

Related Questions