extern is an access-specifier in C which defines a global variable that is visible to all object modules.
-1
votes
1answer
21 views
return makes pointer from integer without a cast - but types are okay?
Just some code. In one file and its header:
// header:
extern char * thessc_config_member_get_config_key(struct config_member_t *m);
// implementation:
inline char * ...
0
votes
1answer
70 views
Why does cout not print extern “C” variable?
Consider the following code:
extern "C" {
#include <lib.h>
}
#include <iostream>
int main() {
unsigned char a='a';
unsigned char b=some_struct_in_libh->unsignedchar;
...
1
vote
2answers
95 views
Behaviour of extern in C
If i declare int Array[10]; in file1.c
In file2.c if I I have a function like this
extern int *Array;
fun()
{
Array[0]=10;
}
Is there any problem with this or not?
2
votes
2answers
43 views
Lesser of two evils when using globals via extern
I'm working with some old code that uses many global variables. I'm fully aware of many of the disadvantages of using global variables, so my question is not about whether I should be using global ...
1
vote
4answers
55 views
How are extern variables defined?
I have a few doubts regarding the use of extern keyword with variables in C. I did go through the links related to this question. However, there are still a few things that I didn't gather very well ...
0
votes
1answer
20 views
Unresolved external symbol for variables in namespace
I have problem with LNK2001: unresolved external symbol error. It shows only when I have all my classes in my namespace and refers to global variables which I use multiple files. Here is example code ...
1
vote
3answers
84 views
Usage of extern keyword in C++
From what I have gathered, the 'extern' keyword in c++ can be used to tell the compiler that a variable is defined in another .cpp file. I was wondering if this definition had to be explicit, or if ...
0
votes
2answers
64 views
using global variables inside main() in c
I'm trying to use global variables, but I'm getting an error when I'm using it inside main function.
Why can't I use "extern" inside main? Codeblocks is showing error in this area only, so I figured ...
0
votes
1answer
34 views
Ctype in python
i have this C++ code in linux ubuntu i want use this method in python by ctype
but can not send parameter to ctype.cdl.funcion
C++ code :
extern "C" unsigned char* getuserdata(int code,unsigned ...
3
votes
3answers
72 views
Extern in multiple files and possible double definition
I was running the following codes compiled together as: gcc A.c B.c -o combined.
Program A:
#include<stdio.h>
int a=1;
int b;
int main()
{
extern int a,b;
fun();
printf("%d %d\n",a,b);
}
...
1
vote
2answers
74 views
c++: “double free or corruption” for global extern variable?
I'm interested in having a global variable one single time across the entire program. So I thought the best way to achieve this is to define it in the header file like so:
extern const std::string ...
2
votes
2answers
61 views
c99 inline semantics with gcc (mspgcc)
I am writing a couple of functions that I would like to inline.
Reading here and using the second c99 inline option with inline on all declarations and definitions, like so:
extern inline void ...
0
votes
3answers
101 views
C Function Definition and the Extern Keyword
I've been trying to understand the linkage error that I'm getting regarding the _sbrk function and stumbled across this function definition in a library.
extern caddr_t _sbrk(int incr);
// ... some ...
1
vote
3answers
52 views
Declaring an extern variable as base and derived class pointers
Say we have a situation like this:
base.h:
class Base { };
derived.h:
#include "base.h"
class Derived : public Base { };
extern Derived *variable;
derived.cpp:
#include "derived.h"
Derived ...
0
votes
2answers
86 views
Extern “C” Usage With Pthreads in OO C++
I have a class that handles all communication with a particular piece of hardware. The hardware requires data updates via one socket, and broadcasts its IP for handshaking purposes on a known (and ...