Questions tagged [translation-unit]

A translation unit is the basic unit of compilation according to standard C++. It consists of the contents of a single source file, plus the contents of any header files directly or indirectly included by it, minus those lines that were ignored using conditional preprocessing statements.

A translation unit is the basic unit of compilation according to standard C++. It consists of the contents of a single source file, plus the contents of any header files directly or indirectly included by it, minus those lines that were ignored using conditional preprocessing statements.

A single translation unit can be compiled into an object file, library, or executable program.

The notion of a translation unit is most often mentioned in the contexts of the One Definition Rule, and templates.

50 questions
0
votes
1 answer

Class' Struct's function declaration in header and definition in cpp. lnk2019 when using function in separate lib

The following will build fine. When I try to use a function in a different library I get linker errors. OtherClass.obj : error LNK2019: unresolved external symbol "public: float __cdecl myClass::myClassStruct::myConvoludedFunction(int,int)"…
codeMetis
  • 420
  • 4
  • 16
0
votes
1 answer

No header files included in file but can still use classes/functions from unincluded header files

Here's some the code from the file in question, called Global.h, which is used in other header files and seems to compile just fine: #pragma once enum SType {null, lab, assignment, testPrep}; enum Code {none, 123, 222, 333, 432}; template
0
votes
1 answer

every method in a separated file c++

After having some memory allocation issues. I'm trying to make every method in a separated file, here is the original program: #include #include #include…
-1
votes
1 answer

Number of translation units vs number of cpp files

We have 2 cases (scenarios). In each case, we have 2 files : main.cpp and file.cpp Case 1 main.cpp : #include #include "file.cpp" // this line is what matters int main () {...} I compile and run by doing: g++ main.cpp -o main &&…
Mohamed Benkedadra
  • 1,964
  • 3
  • 21
  • 48
-3
votes
1 answer

why making unit static makes internal linkage

Can anyone explain why making function static in C++ makes it internally linked only. Is that just from plane standard or some language trick?
1 2 3
4