06-05-2014 04:20 AM
Hello
I have defined & assigning some values to Global files in one of the project files, But the same i am not able to read in other files of the same project.
i have defined as 'extern int x ' in one file & also called in other file by defining 'extern int x'
let me know if you more info needed
Hussain
06-05-2014 08:30 AM
Hello HussainHTS,
I'm not sure I understand your problem. From my understanding, you've defined a variable x as extern in two files, without actually defining it somewhere?
Basically you should define int x in one file and declare it as extern in another file (extern int x).
Does that make sense?
Best regards,
= Nelu F. || National Instruments.
06-05-2014 12:30 PM
Hello Nelu F
Thanks for you valuable inputs, it helped me alot.
if we are using same Global variables in 2 diffrent files do we need to define in both files mentioning exten int x ? or else mentioning in one file is enough?
06-06-2014 12:12 AM
Hello HussainHTS,
Basically, you have to define your variable in one file, using int x;. Then, in your other files, doesn't matter how many, if you want to access that variable, you have to declare the variable as extern, extern int x. You should declare the variable extern in all the files you use it. One declaration per file is enough, if that's what you were wondering about.
Best regards,
= Nelu F. || National Instruments.
06-06-2014 12:50 AM
Hello Nelu F
Yeah, I was looking for this solution. I have got one more query, can we use any data type like visa data types for declaring variables? i am using ViInt32 not int for declaring variables
06-10-2014 12:24 AM
Hello
I am trying to implement this in my program .. but assigning the Global variable is not working
NOTE: I am using LABWINDOWS CVI 5. (Old version)
/////***Test 1 contents****///
extern ViInt32 A= 0; // Assigning ‘0’ to Global variables
extern ViInt32 B= 0;
extern ViInt32 C= 0;
extern ViInt32 D= 0;
if (revision = =1)
{
A=Confirm Popup (“Verifiy”,"Does this unit also have hardware A”);
}
///*** end of Test 1 ***//
If I am trying the access above global variable to Test 5 or some other test program within same project
/////***Test 5 contents****///
If (A)
{
printf (“the Hardware mod is REV A”);
}
Else
{
Printf(“NO Hardware mod find”);
}
//*** end of Test 5 ***//
Now the query is whichever option (YES OR NO) in the confirm POPUP in Test 1. I am getting the output: “NO Hardware mod find”
The reason is the Global Variable is not passing.