top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is translation unit in c++?

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

Share this question
Facebook Share Button Twitter Share Button LinkedIn 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 ?

+1 vote

High level object oriented languages have support of interfaces. What is the best way to create interfaces in C++ ?

...