extern Questions

6

Solved

My project consists of only two source files: a.cpp: const int n = 8; b.cpp: extern const int n; int main() { // error LNK2001: unresolved external symbol "int const n" (?n@@3HB) int m = n;...
John asked 15/2, 2013 at 12:24

2

Is there a way to do an extern alias inside a razor (MVC3) view? I have two versions of the same assembly (i.e. 1.0 and 2.0) with a type that has the same name and namespace and I need a way to sp...
Mopboard asked 30/10, 2012 at 22:13

2

Solved

What's the difference between a static inline, extern inline and a normal inline C function? I've seen some vague explanations about this. As far as I've understood, static inline is not just an in...
Monad asked 28/7, 2014 at 17:10

5

Solved

Why does extern int n not compile when n is declared (in a different file) static int n, but works when declared int n? (Both of these declarations were at file scope.) Basically, why is int n in...
Ichneumon asked 15/5, 2010 at 21:8

8

Solved

If I define a global variable in a .c file, how can I use the same variable in another .c file? file1.c: #include<stdio.h> int i=10; int main() { printf("%d",i); return 0; } fi...
Scarabaeoid asked 22/7, 2011 at 16:17

7

Solved

Is it possible to declare a variable extern constexpr and define it in another file? I tried it but the compiler gives error: Declaration of constexpr variable 'i' is not a definition in .h:...
Diarmid asked 13/5, 2015 at 7:45

1

Solved

Consider a class template S: [s.hpp] template <typename> struct S { void f() { /* ... */ } void g() { /* ... */ } }; This class template also comes with a source file containing a speciali...
Peptonize asked 17/3, 2023 at 1:37

5

Solved

I have the following three files in my code (with most of the code removed. This is just to isolate the issue). global.h: //global.h #ifndef GLOBAL_H #define GLOBAL_H extern const int ARRAYSIZEX;...
Llywellyn asked 20/8, 2018 at 23:25

19

I know that global variables in C sometimes have the extern keyword. What is an extern variable? What is the declaration like? What is its scope? This is related to sharing variables across source...
Eleonoreleonora asked 16/9, 2009 at 14:8

7

I understand that inline by itself is a suggestion to the compiler, and at its discretion it may or may not inline the function, and it will also produce linkable object code. I think that static ...
Whicker asked 19/10, 2008 at 15:9

6

Solved

Can I mix extern and const, as extern const? If yes, does the const qualifier impose it's reign only within the scope it's declared in or should it exactly match the declaration of the translationa...
Chelsiechelsy asked 3/2, 2010 at 9:32

10

Solved

I have a dll which comes from a third party, which was written in C++. Here is some information that comes from the dll documentation: //start documentation RECO_DATA{ wchar_t Surname[200]; wchar...
Perennate asked 17/3, 2009 at 6:26

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

3

I have gone through following two questions: static and extern global variables in C and C++ global variable in C are static or not? Both questions says the two things in different way. Questio...
Tabitha asked 19/2, 2015 at 15:52

2

Solved

Is a function without a storage class specified in its declaration and definition : void func(void); // declaration void func(void) { // implementation } be equivalent to the function with exte...
Warga asked 20/2, 2022 at 12:34

4

Solved

Well, reading "a bit old" book ("The C programming language", second edition, by Dennis Ritchie), I came a cross the following: An external variable must be defined, exactly once, outside of any...
Khanate asked 30/8, 2012 at 14:51

3

Solved

I want to provide a string constant in an API like so: extern const char* const SOME_CONSTANT; But if I define it in my static library source file as const char* const SOME_CONSTANT = "test"; ...
Nominalism asked 20/2, 2013 at 10:4

4

Solved

I'm using VS2008. I'm getting the following error. BUILD: [02:0000000295:ERRORE] c:\wince700\platform\am33x_bsp\src\bootloader\bootpart\bootpart_e.cpp(61) : error C2732: linkage specification cont...
Ostap asked 22/11, 2013 at 7:45

1

Solved

I want to use one of Windows' built-in cursors that are not included in the 'Cursors' class. I found this question to which the answer appears to provide the information I need, but there is ...
Brown asked 29/9, 2021 at 18:25

7

We have this declaration in LCD.c: unsigned char LCD[8][64] = {((unsigned char) 0)}; And in LCD.h we want to have something like: extern unsigned char LCD[][]; We get this error: Error[Pe098...
Emmer asked 20/12, 2011 at 20:31

1

Solved

There is a similar question title here, but in reading the answers it doesn't seem to address that particular question: C: What is the use of 'extern' in header files? (it's more like a &qu...
Upholsterer asked 4/2, 2021 at 23:2

1

Solved

I'm confused about why I need extern or not for int vs char* in the definition in my extern.cpp file. I have the following test program: // extern.cpp extern const int my_int = 1; const char* my_st...
Dunstable asked 20/1, 2021 at 16:25

1

I read that the extern keyword is implicit in the context of functions, so unless you specify otherwise using the static keyword (which if I'm not mistaken is basically a completely separate concep...
Repetition asked 11/11, 2020 at 7:0

5

Solved

Can anyone please tell me is there any special requirement to use either EXTERN or GLOBAL variables in a C program? I do not see any difference in a program like below, if I change from gloabl to e...
Doralia asked 16/4, 2010 at 11:36

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

© 2022 - 2024 — McMap. All rights reserved.