Thread: unknown size of type 'void'

  1. #1
    Registered User
    Join Date
    Mar 2015
    Posts
    3

    unknown size of type 'void'

    Hi, i'm fairly new to C programming and i'm using LabWINDOWS/CVI to compile a c program. the only difference between my program that compiles with no errors and this one is the version of LabWindows. My code is below and the error i get is 'unknown size of type 'void'' and 'Operands of = have illegal types 'void' and 'int''. i realize i probably need to typecast something specific here, but the solutions i have tried haven't done the trick. Any thoughts?

    void acquire_dc_voltage( CAObjHandle TS_seqContextCVI, double which_voltage,
    double *measured_value,
    char reportText[1024], short *errorOccurred,
    long *errorCode, char errorMsg[1024] )
    {
    ERRORINFO errorInfo;
    switch( (int)which_voltage ) // DANGER...int cast may delete lower bits
    {
    case ECG_MUX_SEL_AVDD3V :
    // set ADC mux to AVDD3V
    *(pdaq_fpga_base_addr + OFFSET_ECG_MUX_SEL_REG) = ECG_MUX_SEL_AVDD3V;

  2. #2
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,114
    Your code is not complete. Because of this I can't see the problem.

    Please post the complete, properly FORMATTED code.

  3. #3
    Registered User
    Join Date
    Mar 2012
    Location
    the c - side
    Posts
    373
    Adding to the above, pdaq_fpga_base_addr is clearly critical yet you don't show its declaration or initialisation. According to this thread it needs an initialisation function - assuming it refers to the same version.

  4. #4
    Registered User
    Join Date
    Mar 2015
    Posts
    3
    sorry... my initialization is in another file. I've copied and pasted where it's initialized and i included the rest of the function. For lack of NDA purposes i can't post the entire code. Thanks for taking a look

    Header file for initialization:

    ************************************************** ***************************
    *
    * DLL library global variables
    *
    ************************************************** ****************************/
    // in PDAQ_PCI_access.c

    Code:
    extern ViAddr pdaq_fpga_base_addr;
    reflecting comment that it is used in PDAQ_PCI_access.c, here is the code snippet from there:
    /************************************************** ***********************
    * Local Global variables
    ************************************************** ************************/
    Code:
    unsigned long int pdaq_pci_bar2_size = 0x80000;
    unsigned long int pdaq_pci_bar3_size = 0x100;
    unsigned long int pdaq_pci_bar0_size = 0x100;
    ViAddr pdaq_plx_base_addr;
    ViAddr pdaq_fpga_base_addr;
    ViAddr pdaq_cpld_base_addr;
    ViSession defaultRM, PDAQ3_PLX_FPGA, PDAQ3_PLX_CPLD, PDAQ3_PLX_REGS, ACQ_PC;
    The entire void function where it is used:


    /************************************************** ***************************
    *
    * Name : acquire_dc_voltage()
    *
    * Description :
    * Aquire DC voltage reading from ECG ADC and returns measured value
    * to TestStand
    *
    * Inputs :
    *
    * Outputs :
    *
    ************************************************** ***************************/
    Code:
    void acquire_dc_voltage( CAObjHandle TS_seqContextCVI, double which_voltage,
                             double *measured_value,
                             char reportText[1024], short *errorOccurred,
                             long *errorCode, char errorMsg[1024] )
    {
      ERRORINFO errorInfo;
      switch( (int)which_voltage )   // DANGER...int cast may delete lower bits
      {
         case ECG_MUX_SEL_AVDD3V :
              // set ADC mux to AVDD3V
              *(pdaq_fpga_base_addr + OFFSET_ECG_MUX_SEL_REG) = ECG_MUX_SEL_AVDD3V;
              
              // start ADC conversion
              
              // wait for done...if stalled, report error and break
              
              // read value
              
              // add/subtract offset/gain value (AGND reading)
              
              break;
         default :
              *errorOccurred = TRUE;
              *errorCode = -1;
              sprintf( errorMsg, "ERROR: illegal DC voltage requested \n"
                                 "voltage select number s/b 0 to 15, requested = %05d",
                                 (int)which_voltage );
              sprintf( reportText, "ERROR: illegal DC voltage requested \n"
                                 "voltage select number s/b 0 to 15, requested = %05d",
                                 (int)which_voltage );
              return;
      }; // end switch( which_voltage )

  5. #5
    Registered User
    Join Date
    Mar 2015
    Posts
    3
    I was able to solve this by typecasting the equation as unsigned long. See solution below:

    Code:
    void acquire_dc_voltage( CAObjHandle TS_seqContextCVI, double which_voltage,
                             double *measured_value,
                             char reportText[1024], short *errorOccurred,
                             long *errorCode, char errorMsg[1024] )
    {
      ERRORINFO errorInfo;
      switch( (int)which_voltage )   // DANGER...int cast may delete lower bits
      {
         case ECG_MUX_SEL_AVDD3V :
              // set ADC mux to AVDD3V
              *(unsigned long*)((unsigned long)pdaq_fpga_base_addr + OFFSET_ECG_MUX_SEL_REG) = (unsigned long)ECG_MUX_SEL_AVDD3V;
              
              // start ADC conversion
              
              // wait for done...if stalled, report error and break
              
              // read value
              
              // add/subtract offset/gain value (AGND reading)
              
              break;
         default :
              *errorOccurred = TRUE;
              *errorCode = -1;
              sprintf( errorMsg, "ERROR: illegal DC voltage requested \n"
                                 "voltage select number s/b 0 to 15, requested = %05d",
                                 (int)which_voltage );
              sprintf( reportText, "ERROR: illegal DC voltage requested \n"
                                 "voltage select number s/b 0 to 15, requested = %05d",
                                 (int)which_voltage );
              return;
      }; // end switch( which_voltage )

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 01-24-2011, 05:37 AM
  2. Error-size of te type is unknown
    By as_rule in forum C Programming
    Replies: 5
    Last Post: 08-29-2010, 08:28 AM
  3. unknown size array
    By archriku in forum C Programming
    Replies: 14
    Last Post: 05-07-2009, 11:29 PM
  4. unknown size for type 'void'
    By Noobwaker in forum C Programming
    Replies: 12
    Last Post: 04-05-2006, 06:41 AM
  5. int memCopy(void* , void*, int size)
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 11-19-2001, 03:02 PM

Tags for this Thread