Z
zeecanvas
Hi,
First of all: Yes, I know global variables are bad, but I've a huge
amount of legacy code, and I've to maintain it _as_is_.
I'm maintaining a big program. I moved all (program-wide scope) global
variables outside of the files they were defined it, and created some
files that just hold global variables definitions (just variables,
without any function definition). So, depending on the purpose/category
of variables, they're defined in the proper file.
Then I created headers for these variables, that declare them with the
"extern" keyword.
Yes, the variables are read/write.
But my program crashes now. And I'm about 95% sure that this
rearrangement of variables is the reason... it looks like if when a
function writes or reads a global variable, it's not correctly written
or read.
What can be happening?
Btw, I don't know if this does matter, but the program mixes C and C++
code, taking care of the #ifdef __cplusplus extern "C" etc... (BTW, I
also put this __cplusplus construct in the header file that declares
the global variables as "extern", so that C++ code can access the C
global variables as well.
Thanks a lot in advance for all advice/suggestions.
zee
First of all: Yes, I know global variables are bad, but I've a huge
amount of legacy code, and I've to maintain it _as_is_.
I'm maintaining a big program. I moved all (program-wide scope) global
variables outside of the files they were defined it, and created some
files that just hold global variables definitions (just variables,
without any function definition). So, depending on the purpose/category
of variables, they're defined in the proper file.
Then I created headers for these variables, that declare them with the
"extern" keyword.
Yes, the variables are read/write.
But my program crashes now. And I'm about 95% sure that this
rearrangement of variables is the reason... it looks like if when a
function writes or reads a global variable, it's not correctly written
or read.
What can be happening?
Btw, I don't know if this does matter, but the program mixes C and C++
code, taking care of the #ifdef __cplusplus extern "C" etc... (BTW, I
also put this __cplusplus construct in the header file that declares
the global variables as "extern", so that C++ code can access the C
global variables as well.
Thanks a lot in advance for all advice/suggestions.
zee