Hello all,
I don't believe there's a bug with the handling of booleans in CVI, but I
have a rather strange bug, with a screenshot to prove it:
http://www.gdargaud.net/BugFest/TrueBug.png
Here Second.B is TRUE but still the 'then' case of the 'if' gets executed !
If Second.B is false, the code behaves as expected.
Also Second.B=!Second.B will always return TRUE...
Adding parentheses doesn't help.
I tried to reduce the code to show the problem but the error goes away if I
do so...
This is an attempt that works as expected:
#include <stdio.h>
#define BOOL int
#define FALSE 0
#define TRUE 1
typedef struct sPE_Val {
union {
double D; // For doubles
BOOL B; // For booleans
unsigned int Err; // For error codes
};
int Type; // Indicate what's in the union: VAL_DOUBLE, VAL_BOOL, VAL_ERROR
} tPE_Val;
#define STACK_SIZE 10
int main (int argc, char *argv[]) {
tPE_Val Stack[STACK_SIZE];
int StackTop=4;
#define Second Stack[StackTop-2] // Element below the top of the stack
Second.B=FALSE;
printf("B=%d, !B=%d\n", Second.B, !Second.B);
Second.B=TRUE;
printf("B=%d, !B=%d\n", Second.B, !Second.B);
return 0;
}
I'm at a loss here.
--
Guillaume Dargaud
http://www.gdargaud.net/