• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: 程式編譯後產生Error[984]的錯誤
#6
初級會員
初級會員


查看用戶資訊
我了解了~~原來是這樣啊~~

謝謝版主及各位先進的解說~讓我又上了一課~

真是太感謝了~

發表於: 2009/4/17 15:00
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 程式編譯後產生Error[984]的錯誤
#5
版主
版主


查看用戶資訊
感謝 Master 的說明。 C18 是 ANSI C 的架構,屬於最基本的,不像 PC 所使用的 C 使用上的不方便都考慮進去了。如果在 main ( ) 以後所以宣告的函數要做 Prototype 的宣告,讓 compiler 能認得。

發表於: 2009/4/17 10:51
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 程式編譯後產生Error[984]的錯誤
#4
資深會員
資深會員


查看用戶資訊

void PWM( int Data);
放在main()前面先宣告看看。

主要是C語言中,你的Main()裡面呼叫了PWM(),但是編譯器找不到該函式的位址。所以會編譯錯誤。理論上再次編譯結果應該還是一樣,但是有可能連結清單還在,這時編譯器已經知道PWM()位址(儘管還沒走到PWM()),此時就會編譯成功。

發表於: 2009/4/16 23:32

Edited by master on 2009年04月17日 00:45:03
不要問我哪裡來,我只是個流浪天涯的工程師
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 程式編譯後產生Error[984]的錯誤
#3
初級會員
初級會員


查看用戶資訊
參照:

nicecookie 寫道:
void PWM( int Data)
改成
void PWM( unsigned int Data)
試看看



先謝過這位先進~
我試過 (unsigned int Data)
還是有同樣的錯訊息~

但是我發現一個很有趣的地方~
只要我MPLAB IDE 用8.0的,第一次編譯會錯誤,但是再編譯一次就ok了~錯誤就消失,而且編譯無誤~

但是用8.30版就會一直錯誤,再編譯一次還是存在那錯誤~

發表於: 2009/4/16 21:38
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 程式編譯後產生Error[984]的錯誤
#2
資深會員
資深會員


查看用戶資訊
void PWM( int Data)
改成
void PWM( unsigned int Data)
試看看

發表於: 2009/4/16 21:13
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


程式編譯後產生Error[984]的錯誤
#1
初級會員
初級會員


查看用戶資訊
各位先進~
我寫了一個小程式,編譯後錯產生了這錯誤~
程式如下:

#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
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------