linkage Questions

5

Solved

I am new to C++. I have some doubts regarding multiple definitions error in C++. Let's say I have 3 files in a program. One header file and 2 .cpp files. I have included the header file in b...
Jampan asked 20/9, 2013 at 10:7

2

Solved

As it is known, declaring extern "C" to C++ function makes its name have C linkage, enabling C code to link. My question is - are there other programming languages we can make C++ function names h...
Gonophore asked 31/1, 2014 at 16:3

18

Solved

What exactly does putting extern "C" into C++ code do? For example: extern "C" { void foo(); }
Legation asked 25/6, 2009 at 2:10

1

Solved

There are plenty of questions and answers relating to C++ global variables, such as: static and extern global variables in C and C++ Global variables and constexpr (inline or not?) Is there any se...
Riser asked 29/8, 2023 at 11:0

3

Solved

How can static local variable shared along different translation unit? I know that "static" specifies internal linkage. In case of "static" member function having same address i...
Cherub asked 30/4, 2023 at 10:33

1

I'm new to Rust and I'm trying to understand why can't Rust build faster. I'm specifically talking about the most common case, where I've made a small change in one of my source files and then I ne...
Unwonted asked 11/4, 2021 at 7:12

3

I compiled the following program with both g++ (7.1) and clang++ (xcode 9.0) with -std=c++11 -Wall and get the result: g++ 0x10052c050 0x10052c040 0x10052c040 clang++ 0x108b74024 0x108b74018 0...
Johnsonjohnsonese asked 16/12, 2017 at 5:30

6

Solved

This is a follow-up question to an answer to Is it possible to typedef a pointer-to-extern-“C”-function type within a template? This code fails to compile with g++, Visual C/C++, and Comeau C/C++ ...
Kei asked 2/2, 2011 at 17:30

10

When we are compiling a C program the output is stored in a.out. How can we redirect the compiled output to another file?
Acanthous asked 17/3, 2009 at 11:17

1

Solved

I have link-time error when trying to compile following code with gcc 12.1.0. With clang, msvc and older gcc it compiles as expected. template<typename T> void def() {} template<void (*fo...
Firebug asked 4/6, 2022 at 18:16

3

Solved

In the C++11 standard, what is the difference between constexpr and static constexpr global variables when defined in a header? More specifically, when multiple translation units include the same h...
Predatory asked 31/8, 2017 at 18:2

8

Solved

How can I remove this link warning? You can see code segment that causes this warning. static AFX_EXTENSION_MODULE GuiCtrlsDLL = { NULL, NULL }; //bla bla // Exported DLL initialization is run in c...
Bacciform asked 7/4, 2010 at 12:51

3

Solved

I am aware of how ODR, linkage, static, and extern "C" work with functions. But I am not sure about visibility of types since they cannot be declared static and there are no anonymous nam...
Ansate asked 20/10, 2021 at 8:48

1

According to http://gcc.gnu.org/wiki/Visibility, With -fvisibility=hidden, you are telling GCC that every declaration not explicitly marked with a visibility attribute has a hidden visibility. ...
Gabel asked 24/12, 2019 at 13:52

6

Solved

I have 2 files A.cpp and B.cpp which look something like A.cpp ---------- class w { public: w(); }; B.cpp ----------- class w { public: w(); }; Now I read somewhere (https://en.cppreference.co...
Labaw asked 24/6, 2011 at 8:37

2

Solved

See the following code: /* first file */ int i; /* definition */ int main () { void f_in_other_place (void); /* declaration */ i = 0 return 0; } /* end of first file */ /* start of second fil...
Panther asked 16/10, 2020 at 11:30

2

Solved

Suppose I have two translation units: //A.cpp class X { }; //B.cpp class X { int i; }; Is the above program well-formed? If not, no further questions. If the answer is yes, the program is well-f...
Rosellaroselle asked 17/8, 2020 at 19:7

4

Solved

Take this simple data frame of linked ids: test <- data.frame(id1=c(10,10,1,1,24,8),id2=c(1,36,24,45,300,11)) > test id1 id2 1 10 1 2 10 36 3 1 24 4 1 45 5 24 300 6 8 11 I now want to gr...
Washday asked 27/8, 2012 at 3:38

1

Solved

While I was just checking which linkages are granted to extern local variables I found that some different behavior between compilers for instance if I tested below code as you see in the comments ...
Subway asked 17/4, 2020 at 16:23

1

Solved

I want to forward declare a const variable without giving it external linkage. It seems to me, however, that this is impossible because the extern keyword simultaneously means "this has external li...
Poussin asked 17/2, 2020 at 17:16

1

Solved

Consider the two translation units below. My goal is to inline the function add both in file1.c and main.c. file1.c: extern inline int add(int x, int y) { return x + y; } void g(void) { add(1,...
Metabolism asked 9/2, 2020 at 5:44

1

Solved

I'm trying to interface with a C library, which expects me to provide a pointer to a callback function. As I understand it, according to the standard the callback must have C language linkag...
Horticulture asked 28/1, 2020 at 12:42

5

Solved

What is the difference between static and extern in C?
Bludgeon asked 10/9, 2010 at 12:6

1

Solved

This description on cppreference.com says that The lookup of a dependent name used in a template is postponed until the template arguments are known, at which time [...] ADL examines function de...

1

Solved

During my research for an answer for this question I found (I did not know that before) that gcc and clang allow char arrays to be template arguments if they are declared static. E.g. this code com...
Brandish asked 12/7, 2019 at 14:29

© 2022 - 2025 — McMap. All rights reserved.