LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

passing pointer to arrays in Labwindows CVI/Measurement Studio 6.0

I have had problems with passing a pointer to an array in Labwindows/CVI for some time.  Methods and declarations that compile fine in other C compilers do not seem to work in Labwindows/CVI 6.0.   A recent example along with the compiler error follows:
 
Any thoughts? 
 
 
//a few declares//
struct _myStruct {
  unsigned char SBUF[8];                  /* structure buffer*/
  unsigned int num1;               
  unsigned int num2;                
  unsigned char *aux;                 
  struct _myStruct *next;
};
uchar globalBuffer[8]; /*some global array*/.
struct _myStruct       *myStruct_ptr,         /* mystruct pointer              */
                        *myStruct_end;   /* end of the list              */
 
//function prototype with pointer to array
void myFunction(uchar *buffer);
 
//function itself
void myFunction(uchar *buffer)
{
   uchar i;
    {
      for (i = 0; i < 8; i++)
         buffer[i] = globalBuffer[i];
   }
  
}
//calling the function

 myFunction( &myStruct_end->SBUF);
 

And the compiler error:
 Type error in argument 1 to 'myFunction'; found 'pointer to array 8 of
           unsigned char' expected 'pointer to uchar'.
0 Kudos
Message 1 of 3
(4,055 Views)
myStruct_end->SBUF is itself the pointer to char, the & operator is redundant (and CVI is more picky about that sort of thing):

myFunction(myStruct_end->SBUF);

or you could also do:
myFunction( &myStruct_end->SBUF[0]);

all that assumes that a uchar is the same as an unsigned char, which your code doesn't make clear.
--
Martin
Certified CVI Developer
0 Kudos
Message 2 of 3
(4,030 Views)
Msaxon,
 
That did the trick, thanks.  Now I wish I could remember the other particular pointer syntax that was causing me grief in CVI, but not elsewhere.  I use a few different compilers, and have to incorporate code from others with different styles. Every time I think I have the pointer syntax nailed, I hit one of these.
0 Kudos
Message 3 of 3
(3,988 Views)