Re: 程式編譯後產生Error[984]的錯誤
|
||||
---|---|---|---|---|
初級會員
|
我了解了~~原來是這樣啊~~
謝謝版主及各位先進的解說~讓我又上了一課~ 真是太感謝了~
發表於: 2009/4/17 15:00
|
|||
|
Re: 程式編譯後產生Error[984]的錯誤
|
||||
---|---|---|---|---|
版主
|
感謝 Master 的說明。 C18 是 ANSI C 的架構,屬於最基本的,不像 PC 所使用的 C 使用上的不方便都考慮進去了。如果在 main ( ) 以後所以宣告的函數要做 Prototype 的宣告,讓 compiler 能認得。
發表於: 2009/4/17 10:51
|
|||
|
Re: 程式編譯後產生Error[984]的錯誤
|
||||
---|---|---|---|---|
初級會員
|
參照:
先謝過這位先進~ 我試過 (unsigned int Data) 還是有同樣的錯訊息~ 但是我發現一個很有趣的地方~ 只要我MPLAB IDE 用8.0的,第一次編譯會錯誤,但是再編譯一次就ok了~錯誤就消失,而且編譯無誤~ 但是用8.30版就會一直錯誤,再編譯一次還是存在那錯誤~
發表於: 2009/4/16 21:38
|
|||
|
Re: 程式編譯後產生Error[984]的錯誤
|
||||
---|---|---|---|---|
資深會員
|
void PWM( int Data)
改成 void PWM( unsigned int Data) 試看看
發表於: 2009/4/16 21:13
|
|||
|
程式編譯後產生Error[984]的錯誤
|
||||
---|---|---|---|---|
初級會員
|
各位先進~
我寫了一個小程式,編譯後錯產生了這錯誤~ 程式如下: #include <pic18.h> #define SW3 RA4 #define SW2 RB2 #define ENB RC0 unsigned int temp; unsigned int temp2; void Delay_x_mS(int); void Delay_1mS(void); void Delay_x_uS(int); void Delay_1uS(void); void init(void); //初始化 /*============================================== Main ==============================================*/ void main(void) { init(); while(1) { PORTD = 0x00; PWM(0x55); PORTD = temp2; Delay_x_mS(2000); PORTD = 0x00; Delay_x_mS(1000); RA1 = 0; } } /*============================================== init ==============================================*/ void init(void) { TRISA = 0b11111100; //設定PortA TRISD = 0b00000000; //設定PortD TRISB = 0b11111110; //設定PortB TRISC = 0b11111111; //設定PortB PORTD = 0x00; //清除PORTD } /*============================================== Data ==============================================*/ void PWM( int Data) { unsigned int i; temp2 = 0x00; for( i =7;i>=0;i-- ) { temp = ( Data >> i) & 0x01; Delay_x_mS(125); RA0 = temp; RB0 = temp; temp2 = temp2 << 1; NOP();NOP(); if(RC0==1) temp2 |= 0x01; NOP();NOP(); RA0 = 0; RB0 = 0; } } /*============================================== delay_ms ==============================================*/ void Delay_x_mS( int N_mS ) { unsigned int Loop_mS ; for ( Loop_mS = 0 ; Loop_mS < N_mS ; Loop_mS++ ) { Delay_1mS(); } } //*** Delay 1mS with 16MHz crystal void Delay_1mS(void) { unsigned int Del_1mS; for (Del_1mS = 0 ; Del_1mS < 350 ; Del_1mS ++ ) { asm("nop"); asm("nop"); } } ----------------------------------------------------------------- 但是編譯後,卻發生了錯誤分別是: Warning [361] D:\C-project\test.c; 42.1 function declared implicit int Error [984] D:\C-project\test.c; 74.1 type redeclared 但是,找了許久,改了又改,還是一直有這問題存在一直無法編譯~ 警告的那一行是 PWM(0x55); 而錯誤的另一行的位置很奇怪,是在: void PWM( int Data) {<---------Error 不曉得,問題出在那個地方,還請各位先進及版主幫幫忙~ 萬分感謝~
發表於: 2009/4/16 20:39
|
|||
|