What exactly is a translation unit in C

后端 未结 4 1170
旧巷少年郎
旧巷少年郎 2021-01-03 23:59

The commonly used definition of a translation unit is what comes after preprocessing (header files inclusions, macros, etc along with the source file). This definit

4条回答
  •  感情败类
    2021-01-04 00:42

    However, if one can makes a question out of the above statement and ask: does it mean an implementation is free to consider multiple source files as a single translation unit

    No. The definition is clear:

    A source file together with all the headers and source files included via the preprocessing directive #include is known as a preprocessing translation unit. After preprocessing, a preprocessing translation unit is called a translation unit.

    A translation unit is the result of preprocessing one source file and its includes. The fact that you might translate two translation units at the same time doesn't mean you can treat them as one translation unit.

提交回复
热议问题