这是我的头文件代码。
头文件名16f877a.h
它的代码从此链接获取
我的文件名led.c
#include "16f877a.h" //IC selection
#fuses XT, NOWDT, NOPROTECT, NOLVP
#use delay (clock =20000000) //clock 20MHz
void main(){
while(1){
output_B(0xff); //hex to binary output on port B
delay_us(500); // delay = 500 x clock period.
output_B(0x00);
delay_us(500);
}
}
这些文件位于同一文件夹中
/home/company/Documents/CCPP/PIC/LedProject
我使用UBUNTU 12.04。使用gcc我编译了一个简单的 hello world 程序并且它运行正确。这是我在终端中的命令历史记录
mkdir -p PIC/LedProject
cd PIC/LedProject/
gedit led.c
gcc -Wall -W -Werror led.c -o LedProC
这是我的错误。请帮我解决这个问题
In file included from led.c:1:0:
16f877a.h:91:0: error: ignoring #pragma maxram [-Werror=unknown-pragmas]
16f877a.h:99:0: error: ignoring #pragma memmap INDF_ADDR [-Werror=unknown-pragmas]
16f877a.h:100:0: error: ignoring #pragma memmap TMR0_ADDR [-Werror=unknown-pragmas]
16f877a.h:101:0: error: ignoring #pragma memmap PCL_ADDR [-Werror=unknown-pragmas]
16f877a.h:102:0: error: ignoring #pragma memmap STATUS_ADDR [-Werror=unknown-pragmas]
16f877a.h:103:0: error: ignoring #pragma memmap FSR_ADDR [-Werror=unknown-pragmas]
16f877a.h:104:0: error: ignoring #pragma memmap PORTA_ADDR [-Werror=unknown-pragmas]
16f877a.h:105:0: error: ignoring #pragma memmap PORTB_ADDR [-Werror=unknown-pragmas]
16f877a.h:106:0: error: ignoring #pragma memmap PORTC_ADDR [-Werror=unknown-pragmas]
16f877a.h:107:0: error: ignoring #pragma memmap PORTD_ADDR [-Werror=unknown-pragmas]
16f877a.h:108:0: error: ignoring #pragma memmap PORTE_ADDR [-Werror=unknown-pragmas]
16f877a.h:109:0: error: ignoring #pragma memmap PCLATH_ADDR [-Werror=unknown-pragmas]
16f877a.h:110:0: error: ignoring #pragma memmap INTCON_ADDR [-Werror=unknown-pragmas]
16f877a.h:111:0: error: ignoring #pragma memmap PIR1_ADDR [-Werror=unknown-pragmas]
16f877a.h:112:0: error: ignoring #pragma memmap PIR2_ADDR [-Werror=unknown-pragmas]
16f877a.h:113:0: error: ignoring #pragma memmap TMR1L_ADDR [-Werror=unknown-pragmas]
16f877a.h:114:0: error: ignoring #pragma memmap TMR1H_ADDR [-Werror=unknown-pragmas]
16f877a.h:115:0: error: ignoring #pragma memmap T1CON_ADDR [-Werror=unknown-pragmas]
16f877a.h:116:0: error: ignoring #pragma memmap TMR2_ADDR [-Werror=unknown-pragmas]
16f877a.h:117:0: error: ignoring #pragma memmap T2CON_ADDR [-Werror=unknown-pragmas]
16f877a.h:118:0: error: ignoring #pragma memmap SSPBUF_ADDR [-Werror=unknown-pragmas]
16f877a.h:119:0: error: ignoring #pragma memmap SSPCON_ADDR [-Werror=unknown-pragmas]
16f877a.h:120:0: error: ignoring #pragma memmap CCPR1L_ADDR [-Werror=unknown-pragmas]
16f877a.h:121:0: error: ignoring #pragma memmap CCPR1H_ADDR [-Werror=unknown-pragmas]
16f877a.h:122:0: error: ignoring #pragma memmap CCP1CON_ADDR [-Werror=unknown-pragmas]
16f877a.h:123:0: error: ignoring #pragma memmap RCSTA_ADDR [-Werror=unknown-pragmas]
16f877a.h:124:0: error: ignoring #pragma memmap TXREG_ADDR [-Werror=unknown-pragmas]
16f877a.h:125:0: error: ignoring #pragma memmap RCREG_ADDR [-Werror=unknown-pragmas]
16f877a.h:126:0: error: ignoring #pragma memmap CCPR2L_ADDR [-Werror=unknown-pragmas]
16f877a.h:127:0: error: ignoring #pragma memmap CCPR2H_ADDR [-Werror=unknown-pragmas]
16f877a.h:128:0: error: ignoring #pragma memmap CCP2CON_ADDR [-Werror=unknown-pragmas]
16f877a.h:129:0: error: ignoring #pragma memmap ADRESH_ADDR [-Werror=unknown-pragmas]
16f877a.h:130:0: error: ignoring #pragma memmap ADCON0_ADDR [-Werror=unknown-pragmas]
16f877a.h:131:0: error: ignoring #pragma memmap OPTION_REG_ADDR [-Werror=unknown-pragmas]
16f877a.h:132:0: error: ignoring #pragma memmap TRISA_ADDR [-Werror=unknown-pragmas]
16f877a.h:133:0: error: ignoring #pragma memmap TRISB_ADDR [-Werror=unknown-pragmas]
16f877a.h:134:0: error: ignoring #pragma memmap TRISC_ADDR [-Werror=unknown-pragmas]
16f877a.h:135:0: error: ignoring #pragma memmap TRISD_ADDR [-Werror=unknown-pragmas]
16f877a.h:136:0: error: ignoring #pragma memmap TRISE_ADDR [-Werror=unknown-pragmas]
16f877a.h:137:0: error: ignoring #pragma memmap PIE1_ADDR [-Werror=unknown-pragmas]
16f877a.h:138:0: error: ignoring #pragma memmap PIE2_ADDR [-Werror=unknown-pragmas]
16f877a.h:139:0: error: ignoring #pragma memmap PCON_ADDR [-Werror=unknown-pragmas]
16f877a.h:140:0: error: ignoring #pragma memmap SSPCON2_ADDR [-Werror=unknown-pragmas]
16f877a.h:141:0: error: ignoring #pragma memmap PR2_ADDR [-Werror=unknown-pragmas]
16f877a.h:142:0: error: ignoring #pragma memmap SSPADD_ADDR [-Werror=unknown-pragmas]
16f877a.h:143:0: error: ignoring #pragma memmap SSPSTAT_ADDR [-Werror=unknown-pragmas]
16f877a.h:144:0: error: ignoring #pragma memmap TXSTA_ADDR [-Werror=unknown-pragmas]
16f877a.h:145:0: error: ignoring #pragma memmap SPBRG_ADDR [-Werror=unknown-pragmas]
16f877a.h:146:0: error: ignoring #pragma memmap ADRESL_ADDR [-Werror=unknown-pragmas]
16f877a.h:147:0: error: ignoring #pragma memmap ADCON1_ADDR [-Werror=unknown-pragmas]
16f877a.h:148:0: error: ignoring #pragma memmap EEDATA_ADDR [-Werror=unknown-pragmas]
16f877a.h:149:0: error: ignoring #pragma memmap EEADR_ADDR [-Werror=unknown-pragmas]
16f877a.h:150:0: error: ignoring #pragma memmap EEDATH_ADDR [-Werror=unknown-pragmas]
16f877a.h:151:0: error: ignoring #pragma memmap EEADRH_ADDR [-Werror=unknown-pragmas]
16f877a.h:152:0: error: ignoring #pragma memmap EECON1_ADDR [-Werror=unknown-pragmas]
16f877a.h:153:0: error: ignoring #pragma memmap EECON2_ADDR [-Werror=unknown-pragmas]
16f877a.h:206:1: error: unknown type name ‘data’
16f877a.h:206:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before numeric constant
16f877a.h:207:1: error: unknown type name ‘sfr’
16f877a.h:207:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before numeric constant
16f877a.h:208:1: error: unknown type name ‘data’
16f877a.h:208:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before numeric constant
16f877a.h:209:1: error: unknown type name ‘sfr’
16f877a.h:209:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before numeric constant
16f877a.h:267:1: error: unknown type name ‘sbit’
16f877a.h:267:1: error: expected declaration specifiers or ‘...’ before ‘(’ token
16f877a.h:268:1: error: unknown type name ‘sbit’
16f877a.h:485:1: error: expected declaration specifiers or ‘...’ before ‘(’ token
16f877a.h:486:1: error: unknown type name ‘sbit’
16f877a.h:486:1: error: expected declaration specifiers or ‘...’ before ‘(’ token
led.c:2:2: error: invalid preprocessing directive #fuses
led.c:3:2: error: invalid preprocessing directive #use
led.c:4:6: error: return type of ‘main’ is not ‘int’ [-Werror=main]
led.c: In function ‘main’:
led.c:6:3: error: implicit declaration of function ‘output_B’ [-Werror=implicit-function-declaration]
led.c:7:3: error: implicit declaration of function ‘delay_us’ [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
bellvantage@BVPC00024:~/Documents/CCPP/PIC/LedProject$ mkdir -p PIC/LedProject
bellvantage@BVPC00024:~/Documents/CCPP/PIC/LedProject$ cd PIC/LedProject/
bellvantage@BVPC00024:~/Documents/CCPP/PIC/LedProject/PIC/LedProject$ gedit led.c
bellvantage@BVPC00024:~/Documents/CCPP/PIC/LedProject/PIC/LedProject$ gcc -Wall -W -Werror led.c -o LedProC
gcc: error: led.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
我为我的电路参考了这个博客