2010-08-06 3 views
2

제목에서 알 수 있듯이 컴파일 할 때이 오류가 계속 발생합니다. 이 오류를 인터넷 검색에서 사람들이이 헤더 파일에 선언하지만 내 기능은 정적이며이 헤더 파일에없는되지 않는다는 것을 말했다, 나는 it.`에게C :의 컴파일러 오류 : '' 'before'* '토큰

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

static int cardinit(cardinfo *card); // <-- 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; 
} 

`

답변

16

cardinfo 구조체가 오류가있는 줄에서 여전히 정의되지 않았습니다. 그 전에 앞으로 선언을 넣어 : 당신은cardinfo 구조의 정의 뒤에 줄을

static int cardinit(cardinfo *card); 

을 둘 필요가

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

나를 이길;) –

+1

C90에서'static int cardinit (struct cardinfo * card);를 forward 선언문과 함께 말해야합니다. C99에서도 여전히 그렇습니까? –

+0

처음에는 C++로 컴파일 된 더미 코드가 c로 변경되었지만 'struct'가 필요합니다. – Vladimir

8

의이 줄을 프로토 타입 코드 :

static int cardinit(cardinfo *card); 

은 cardinfo 구조의 정의 뒤에 추가해야합니다.

4

.

1

그 줄에서 컴파일러는 아직 cardinfo가 구조체라는 것을 모릅니다. 줄을 앞에 붙이십시오. struct cardinfo;

0

컴파일러가 구문 분석 할 때 인식하지 못하는 유형의 입력 변수가있는 함수를 선언했습니다. 즉 구조체 정의는 함수 선언을 따릅니다. 그런 코드를 컴파일하고자 할 때 구조체의 선언을하십시오.

컴퓨터 프로그래밍에서, 순방향 선언 프로그래머 아직 완전한 정의를 부여되지 않은 (예를 들면, 타입, 변수 또는 함수 엔티티를 나타내는) 식별자 선언 이다.

link에는 완전한 선언이 필요하지 않은 경우에 대한 유용한 기사가 있습니다.