What is a “translation unit” in C++

前端 未结 11 690
既然无缘
既然无缘 2020-11-21 07:56

I am reading at the time the \"Effective C++\" written by Meyers and came across the term \"translation unit\".

Could somebody please give me an explanation of:

相关标签:
11条回答
  • 2020-11-21 08:35

    In addition to the ODR, the translation unit is important in the definition of unnamed namespaces, which replaces one of the old uses of "static".

    I guess I still don't have enough points to add a comment under the top answer.

    0 讨论(0)
  • 2020-11-21 08:36

    In my view, a "translation unit" is typically a single "post-preprocessing" source file. You can get more details on this MSDN page. http://msdn.microsoft.com/en-us/library/bxss3ska(v=vs.80).aspx

    0 讨论(0)
  • 2020-11-21 08:37

    Every cpp/c (implementation) file will be converted into a translation unit (ie.,object file (.obj)) headers in the cpp file will be replaced with the actual text from the header files.

    0 讨论(0)
  • 2020-11-21 08:46

    As others have said, a translation unit is basically the contents of a source file after preprocessing. It's the topmost production in the language grammar; you would only need to worry about it if you were writing a C or C++ compiler.

    0 讨论(0)
  • 2020-11-21 08:47

    The book makes it clear enough. When Meyers referes to a "translation Unit", he means a source code file.

    0 讨论(0)
提交回复
热议问题