LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Preprocessor command, assigned the variable and then compare the variable to int. How can I get around this?

#define ON 1
#define OFF 0
in seperate code

int variable = ON;
variable is globally define for that module.
in seperate code
if (variable == ON)
{


}

the complier errors off on the if (variable==ON)
My guess variable is variable in of type int and ON is a preprocessor command. Therefore it is a mismatch and complier doesn't like it. How can I get around this.
thank
Mahen
0 Kudos
Message 1 of 3
(3,050 Views)
Mahen

What is the exact message of the compiler?
I think the error is, that the compiler does not find the definition of ON
and OFF. Is it in the same source file?
If not, try to put it into an .h file and include it where you need it.

Stephan

"Mahen" schrieb im Newsbeitrag
news:101-50650000000800000011150000-982303670000@quiq.com...
> Preprocessor command, assigned the variable and then compare the
> variable to int.
>
> How can I get around this?
>
> #define ON 1
> #define OFF 0
> in seperate code
>
> int variable = ON;
> variable is globally define for that module.
> in seperate code
> if (variable == ON)
> {
>
>
> }
>
> the complier errors off on the if (variable==ON)
> My guess variable is variable in of type int and ON is a preprocessor
> c
ommand. Therefore it is a mismatch and complier doesn't like it. How
> can I get around this.
> thank
> Mahen
0 Kudos
Message 2 of 3
(3,050 Views)
I think I have got it fixed

bool.h file

#define BOOLEAN int
#define TRUE 1
#define FALSE 0

Then you can define variable as

BOOLEAN variable

use the variable

variable=TRUE

If variable==TRUE
{

}

Thanks for your help
0 Kudos
Message 3 of 3
(3,050 Views)