static
in this context means “local” (to the translation unit). There will be multiple copies of read_mess
in your program, one per translation unit which is not the same thing as a header file. (In your case you can most likely approximate “translation unit” as .cpp or .c or .cc file).
Probably what you meant to do was to declare an extern
variable, or static
class member and define it in just one translation unit.
In practice using extern
means in your header file you want to write:
extern bool read_mess;
But in one and only one other place that isn’t a header:
bool read_mess = false;
Related Posts:
- The static keyword and its various uses in C++
- What is the printf format specifier for bool?
- What is the difference between a static and const variable?
- Getting error “a nonstatic member reference must be relative to a specific object” while both member are in the same class
- Static array vs. dynamic array in C++
- C++ #include guards
- C++ #include guards
- C++ printing boolean, what is displayed?
- What is the difference between a .cpp file and a .h file?
- Using G++ to compile multiple .cpp and .h files
- Too many arguments to function
- function does not take 1 arguments c++
- error: ISO C++ forbids in-class initialization of non-const static member
- cmath vs math.h (And similar c-prefixed vs .h extension headers)
- Does static constexpr variable inside a function make sense?
- Converting bool to text in C++
- Why virtual & static keywords aren’t allowed outside class declaration?
- Member function with static linkage
- What is a lambda expression in C++11?
- How to convert string to char array in C++?
- ld: symbol(s) not found for architecture x86_64 error
- C++ string to double conversion
- How do I print out the contents of a vector?
- ‘was not declared in this scope’ error
- Good input validation loop using cin – C++
- Is there a C++ decompiler?
- What is a dangling pointer?
- undefined reference to WinMain@16 (codeblocks)
- Why use ‘glad’ library for opengl initialization? [duplicate]
- What does `*&` in a function declaration mean?
- (->) arrow operator and (.) dot operator , class pointer
- How to reverse an std::string? [duplicate]
- What is the C version of RMI
- Difference between ‘strcpy’ and ‘strcpy_s’?
- What is uintptr_t data type
- Why am I getting this redefinition of class error?
- error: redefinition of class
- How to convert a std::string to const char* or char*
- What is move semantics?
- unsigned int vs. size_t
- error: expected primary-expression before ‘)’ token (C)
- What does -> mean in C++?
- Why doesn’t std::vector::push_front() exist?
- Fastest way to check if a file exist using standard C++/C++11,14,17/C?
- Invalid use of non-static member function c++
- Is std::stoi actually safe to use?
- C++ forbids variable-size array
- Fill array with random numbers within a specified range (C++)
- Remove an array element and shift the remaining ones
- Right way to split an std::string into a vector
- string subscript out of range error
- push_back vs emplace_back
- No operator << matches these operands
- Returning an empty string : efficient way in c++
- How to find the size of an int[]?
- Append an int to a std::string
- Decimal to hex conversion c++ built-in function
- C++ IDE with repl?
- Already defined in .obj – no double inclusions
- expected unqualified-id before string constant
- C++: Access violation writing location
- error: strcpy was not declared in this scope
- how to print a string to console in c++
- How to call a parent class function from derived class function?
- Error: No instance of constructor matches the argument list
- How can I get the list of files in a directory using C or C++?
- RPN Calculator for C++
- What does `Fatal Python error: PyThreadState_Get: no current thread` mean?
- Debug Assertion Failed: _CrtIsValidHeapPointer(block)
- gdb error not in executable format: File format not recognized
- C++ Erase vector element by value rather than by position?
- C++ – include unistd.h: why not cunistd?
- Dynamically allocated string array, then change it’s value?
- Use the auto keyword in C++ STL
- c++ –
- C++ – statement cannot resolve address for overloaded function
- What’s the difference between * and & in C?
- is there is a compiler which convert c++ code into mips assembly language
- Undefined reference to a static member
- How to sort with a lambda?
- stoi function gives error: std::invalid_argument at memory location 0x0035E8D8. c++
- Stack around the variable ‘ ‘ was corrupted
- The difference between cin.ignore and cin.sync
- casting int to char using C++ style casting
- How to print (using cout) a number in binary form?
- What is the job of autogen.sh when building a c++ package on Linux
- LPCSTR, LPCTSTR and LPTSTR
- How to do std::string indexof in C++ that returns index of matching string?
- MSVCP120d.dll missing
- Modulo operator with negative values [duplicate]
- Finding the type of an object in C++
- C++ Simple Dice roll – how to return multiple different random numbers [duplicate]
- How can I get a file’s size in C++?
- Why can’t I make a vector of references?
- What does “-Wall” in “g++ -Wall test.cpp -o test” do?
- C++ equivalent of StringBuffer/StringBuilder?
- Struct with template variables in C++
- error: no member function declared in class
- Why does my program give “NULL used in arithmetic”
- no matching function to call for “getline”