U
Uenal Mutlu
If "extern" is specified for a variable which is already in the same cpp file
then the compiler (VS6) creates a new instance of the var in each thread.
Is this a bug or a feature?
Which is standard conform?
Example:
test.cpp:
int gi = 0;
test.cpp (ie. same file)
thread_func(...)
{
extern int gi;
gi++;
//...
}
thread1 starts and exits. gi now 1 as expected.
thread2 starts and exits. gi now has value 1. Shouldn't it be 2 ?
If the "extern" declaration is not used then gi is 2.
Or, if the "extern" declaration is used and gi is moved to another cpp
then too is gi 2.
What's the correct (std conform) behaviour?
// U.Mutlu
then the compiler (VS6) creates a new instance of the var in each thread.
Is this a bug or a feature?
Which is standard conform?
Example:
test.cpp:
int gi = 0;
test.cpp (ie. same file)
thread_func(...)
{
extern int gi;
gi++;
//...
}
thread1 starts and exits. gi now 1 as expected.
thread2 starts and exits. gi now has value 1. Shouldn't it be 2 ?
If the "extern" declaration is not used then gi is 2.
Or, if the "extern" declaration is used and gi is moved to another cpp
then too is gi 2.
What's the correct (std conform) behaviour?
// U.Mutlu