LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in assignment statment

[1] I can't find the version of C you're using. ANSI 1989, Addendum 1994/1996, ANSI 1999?
[2] The following statements show an error. I believe the error is bogus.

# define max(a, b) ((a) < (b))? (b): (a)
# define min(a, b) ((a) < (b))? (a): (b)

enum { PSAMaxLine          = 160                      // Maximum characters in a line
     , PSAMaxIndent        =  28                      // Maximum nesting levels
     , PSAIndentInc        =   2                      // Columns to indent at each level
     };

typedef struct Thread { int    Indent;
                        char   Chr;
                        char * Prefix[PSAMaxIndent+1];
                      } Thread;
                     
                     // Indent  Chr            PSAPrefix
Thread  TArray[1] = { { 0,      '|', "\0 | | | | | | | | | | | | |" } }; // TArray

int           PSADebugFlag =   1;                     // Global Debug (0/OFF 1/ON)


void PSAEnter(char * Name, char * Data){              // Output Procedure Enter line
  TArray[0].Prefix[max(0, min(TArray[0].Indent, PSAMaxIndent))] = TArray[0].Chr;
}; // PSAEnter

error: Operands of = have illegal types 'pointer to char' and 'char'.

The expression on both sides of the '=' sign are 'chars'

The following expression has worked.

char * Prefix =
"\0 | | | | | | | | | | | | |";
Prefix[max(0, min(Indent, PSAMaxIndent))] = '|';

[3] 'inline int max(a, b) { return ((a) < (b))? (b): (a); }'
    is valid ANSI 1999 C but invalid NI C.

[4] [2] and [3] have been compiled as correct on ANSI 1999 compliant C compilers.

art
0 Kudos
Message 1 of 2
(2,853 Views)

I'd have to agree with CVI's ANSI89 compiler: on the left of the assignment statement in error you have selected the .Prefix structure component - you have defined this as an array of character pointers, so de-referencing it once will give you a character pointer, not a character. Perhaps a typo has crept in, somewhere?

JR

0 Kudos
Message 2 of 2
(2,831 Views)