这是我的 main.c 程序,由于“需要结构/联合”而导致构建失败。我正在使用 pic 13f877a 微控制器。如果有人能告诉我此构建失败的原因,我将非常感激。还有另一个警告说“36.1 函数声明为隐式 int”。这也是什么意思?
#include<htc.h>
#define _XTAL_FREQ 4000000
__CONFIG(0X3F39);
void main(){
int a;
TRISB = 0b00010000; //RB4 as Input PIN (ECHO)
TRISC = 0b00000000; //C as Output PINs (LED)
T1CON = 0b00010000; //Initialize Timer Module
while(1){
TMR1H = 0; //Sets the Initial Value of Timer
TMR1L = 0; //Sets the Initial Value of Timer
PORTC = 0b00000000;
PORTB.F0 = 1; //TRIGGER HIGH
Delay_us(10); //10uS Delay
PORTB.F0 = 0; //TRIGGER LOW
while(!PORTB.F4){
T1CON.F0 = 1;
}
while(PORTB.F4){
T1CON.F0 = 0;
}
a = (TMR1L | (TMR1H<<8)); //Reads Timer Value
a = a/58; //Converts Time to Distance
a = a + 1; //Distance Calibration
if(a>=2 && a<=400){
//with in the range
PORTC = 0b11111111;
} else {
//out of range
PORTC = 0b00000000;
}
Delay_ms(400);
}
}
Build C:\Users\user\Desktop\SmartDustbin for device 16F877A
Using driver C:\Program Files (x86)\HI-TECH Software\PICC\9.81\bin\picc.exe
Make: The target "C:\Users\user\Desktop\main.p1" is out of date.
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.81\bin\picc.exe" --pass1 C:\Users\user\Desktop\main.c -q --chip=16F877A -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Error [196] C:\Users\user\Desktop\main.c; 15.10 struct/union required
Warning [361] C:\Users\user\Desktop\main.c; 16.1 function declared implicit int
Error [196] C:\Users\user\Desktop\main.c; 17.10 struct/union required
Error [196] C:\Users\user\Desktop\main.c; 19.16 struct/union required
Error [196] C:\Users\user\Desktop\main.c; 20.10 struct/union required
Error [196] C:\Users\user\Desktop\main.c; 22.15 struct/union required
Error [196] C:\Users\user\Desktop\main.c; 23.10 struct/union required
Warning [361] C:\Users\user\Desktop\main.c; 36.1 function declared implicit int
********** Build failed! **********