Hello,
I am currently experiencing the following problem with the use of static or global variables with the C6455 DSP
Working Example: Using a single source file.
static int a;However, when I try to break the above into two source files and using extern, the code starts
static int b;
static int output;
void PerformTest(void)
{
a = 1;
b = 1;
output = 0;
if((a == 1) && (b==1))
{
output = Test(a, b);
}
cout << output;
}
The above example works as I get the correct output.
behaving abnormally.
-------------------------------------------------------------------------------------------------
file1.c
int a;
int b;
int output;
void PerformTest(void)
{
a = 1;
b = 1;
output = 0;
TestFromFile2();
}
-------------------------------------------------------------------------------------------------
file2.c
extern int a;
extern int b;
void TestFromFile2(void)
{
if(a==1) && (b==1)
{
output = Test(a,b);
}
cout << output;
}
Using the code above, I get a different and incorrect output than from the first example where I have a single source file with static variables. It appears when I try to make the variables global, and do an extern on them, there is some sort of discrepancy going on, and I can’t quite figure out where the problem is. Any help is greatly appreciated. I included the .map file for the non working case. Hopefully this proves useful for someone more knowledgeable than me in this area.
Note: Test(int, int) is a vendor supplied function, I have no visibility into it aside from the inputs/outputs.