All Questions
117
questions
0
votes
1
answer
55
views
Why I didnot get Multiple definition Error?
#include <stdio.h>
#define MAX 5
static int data = 10;
int increment(void *);
int increment(void *ptr)
{
int *p = ptr;
static int data =15;
for (int loop=0; loop < MAX; loop++...
1
vote
2
answers
82
views
How to call global static method from class static method in C#?
The following program compiles et executes just fine in recent versions of C#, where a Main function is not necessary:
Module2.SayHelloDouble();
static class Module1
{
public static void SayHello(...
0
votes
1
answer
201
views
rust: static map initialization with enum keys
First up: I am a very newbie with Rust; learning.
This issue arises most probably from thinking in terms of other languages. So most probably the best solution is doing this in a completely different ...
0
votes
0
answers
48
views
Are static class methods and variables visible form different modules (libs, dlls, exes)?
The case is quite simple - we had a discussion based on experiencing some linker issues, where colleagues of mine were stating, that we are unable to access the static methods and variables that are ...
0
votes
1
answer
67
views
static variables not initialized in C [closed]
In a C program I have this code in a file. It wants to use a static global variable to control verbose output. But the variable is not what I assigned, so I started to play.
static int _varA = 0;
...
1
vote
1
answer
92
views
Storage of uninitialized global static variable in C programming
As I learn, uninitialized global static variable take memory space in bss. But while i am declaring a global static variable in my c program, the size of the bss is not increasing.
I tried:
#include&...
-2
votes
4
answers
495
views
Static variable in global and local scope
I want to know what is the difference between declaring a static variable locally and globally, because in below example.
If results do not impact, then why we have two scopes for static?
#include <...
0
votes
1
answer
41
views
gcc complaining "multiple definition of 'funname' ", then how to declare a global character array? [duplicate]
I have a header error.h, and this is where I want to declare my global character array funname.
My idea is to declare funname in error.h, and include this header in all of my *.c files. funname stores ...
1
vote
2
answers
929
views
Why and where to use a global variable and a static global variable in C?
I have read about global and local variables and static keyword, but i dont know which is the difference between something like this:
int x; //Global variable
int main(){
//Code...
}
And this:
...
1
vote
1
answer
672
views
What is the best practice to avoid using static global variable?
Hi im creating a program in python and im running into what i think might be unprofessional practice. so im aware global variables are almost never the answer or good news. but consider this function ...
0
votes
1
answer
43
views
static vector in recursion vs global vector
USING GLOBAL VECTOR
vector<int> r;
vector<int> inorderTraversal(TreeNode* root) {
if(root==NULL)
return r;
inorderTraversal(root->left);
r.push_back(root->val);
...
0
votes
1
answer
169
views
Initialize static member of class which is itself a class in subclass
I have two classes of which one is a subclass of the other. The classes are layed out as a singleton. So the base class contains a static member which is set to the only instance of that class and can ...
0
votes
1
answer
64
views
C++ static vs global with pointers?
In C++11 I wrote (in global):
static MallocMetadata *dummy_block = &MallocMetadata{};
And I got a warning that I am taking address of temporary.
Why is this a warning? isn't static living until ...
1
vote
1
answer
2k
views
are static variables "thread safe" in javascript
I am making a node.js web server that handles large payloads, computations and copies, for example I need to with a deep copy of a large object:
const largeObject = { bla: "bla" } // ...
...
0
votes
1
answer
55
views
using static array when calls external interface
I have a question about using pointer of static variables as input arguments between c files.
I though that i have to declear and define array as a global since the array pointer is tranmitted to ...