开发者

Compiler Error in C: expected ')' before '*' token

开发者 https://www.devze.com 2023-01-11 00:27 出处:网络
As the title says, keep getting this error when trying to compile. From Googling this error people have said that it is not declared in the header file but my function is static and it is not in a hea

As the title says, keep getting this error when trying to compile. From Googling this error people have said that it is not declared in the header file but my function is static and it is not in a header file, I prototyped it.`

#include <recGbl.h>
#include <devSup.h>
#include <devLib.h>
#include <drvIpac.h>
#include <dbScan.h>
#include <epicsExport.h>

static int cardinit(cardinfo *card);开发者_StackOverflow   // <-- line that gives the error

typedef struct cardinfo{
  struct cardinfo *next;

  struct io_mem_read *pMem;   /* IP register (A16) mem address */
  word *rambase;             /* RAM conversion memory mem address*/

  int isconfigured;
  int doram;   /* 1 if we are using the RAM to output data.
          0 if we are writing to registers (AO style) */

  int cardnum;
  int vmeslotnum;
  int ipslotnum;


  /* these values mirror the hardware registers */
  word csr;
  word offset;
  word numconv;
  word clockrate;
  word vectnum;


  word dacval[MAXSIGNAL];

  word oldispresent;
  /* used to detect a reinsertion of a carrier card.
     see subroutine ispresent() below. */

  /* use to update process variables */
  IOSCANPVT ioscanpvt;
} cardinfo;

static int Hy8402init(int vmeslot, int ipslot, int clockrate) {
    cardinfo *card;

    card->vmeslotnum = vmeslot;
    card->ipslotnum = ipslot;
    card->cardnum = 1;

    card->clockrate = clockrate;
    card->vectnum = 10;

    cardinit(card);

return TRUE;
}

static int cardinit(cardinfo *card){
  word rprobe;
  int res;
  volatile word *ramptr;

  card->pMem= ipmBaseAddr(card->vmeslotnum,
              card->ipslotnum,ipac_addrIO);  
  if (card->pMem==NULL){
    printf("Error in %s",devstr);
    printf( "%s: Cannot determine base address\n",devstr);
    return FALSE;
  }

  res=devReadProbe(sizeof (word),(char *) card->pMem,(char *) &rprobe);
  if (res!=OK){
    printf("%s: NO DEVICE at %x (vmeslot %d, ipslot %d)\n",devstr,
       (int)card->pMem,
       card->vmeslotnum,card->ipslotnum);
    return FALSE;
  }
return TRUE;
}

`


cardinfo struct is still undefined on the line with error. Put a forward declaration before it:

struct cardinfo;
static int cardinit(struct cardinfo *card);


This line of code:

static int cardinit(cardinfo *card);  

should be added after the definition of your cardinfo structure.


You need to put the line

static int cardinit(cardinfo *card);

after the definition of the cardinfo structure.


At that line, the compiler doesn't yet know that cardinfo is a struct. Precede it with the line struct cardinfo;


You have declared a function which has a input variable of a type which the compiler is not aware when it parses it. i.e the struct defintion follows your function declaration. So please do a forward declaration of the structure when you want to compile such code.

In computer programming, a forward declaration is a declaration of an identifier (denoting an entity such as a type, a variable, or a function) for which the programmer has not yet given a complete definition.

This link has a nice article on when full declarations are not required.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号