top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

What is translation unit in c++?

+2 votes
86 views
What is translation unit in c++?
posted Mar 25, 2014 by Maninder Bath

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

0 votes

C++ programs are organised into different source files (.cpp, .cxx etc). When you consider a source file, at the pre-processing stage, some extra content may get added to the source code ( for example, the contents of header files included) and some content may get removed ( for example, the part of the code in the #ifdef of #ifndef block which resolve to false/0 based on the symbols defined). This effective content is called a translation unit.

answer Mar 26, 2014 by Parampreet Kaur
Similar Questions
+1 vote

I am using the -fdump-translation-unit option of GCC to parse C enum/structure/union/arrays. Consider the below code

enum eDAY
{
 monday = 0,
 tuesday,
 wednesday
};

enum eDAY day = monday;

I can get all the members of the enumerator parsing the dump of GCC. But if the below declaration was not present

enum eDAY day = monday;

GCC's dump doesn't have any information about the members of the enumerator. The same problem exists with structures/unions etc. How can I solve this problem. Is there some kind of optimization flag which I need to turn off so that GCC parses all the objects even if it is not used ?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...