We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am getting an error for void main() function.. Please help me. I am using AT89C51.
I'm not sure you've provided anywhere near enough context to provide a useful answer. You'll need to examine your code, and determine if it's actually compliant C code.
You might consider :
int main(void) { // .. while(1); }
Actually, it is giving me error in every line of main function. my code is as follows. Plz help me. I tried changing sequence also. Now giving error in void initialise_serial_com(void)
#include<reg51.h> #include<string.h> #include<absacc.h> #include<stdlib.h> #include<ctype.h> #define buffer 110 sbit R1 = P2^7; sbit R2 = P2^6; sbit R3 = P2^5; sbit wpt = P2^4; sbit buzz = P2^3; void read_notification(); void SMSString(unsigned char *text); void delete_msg(void); void store_msg(unsigned char msg_array[]); void check_auth_no(unsigned char msg_array[]); void check_msg(); void tx0(unsigned char x); void wrong_pass(); unsigned char msg_no; unsigned char MyBuff[]; bit NewMessage = 0; bit TI_flag = 0; bit flag=0; unsigned char MyBuff[20], k = 0; unsigned char abc; unsigned char code Response[] = "+CMTI"; unsigned char store[10]; unsigned char Mob_no[]="8956112239"; unsigned char pass[]="123456" void initialise_serial_com(void) { TMOD=0x20; SCON=0x51; TH1 = 0xFD; TL1 = 0xFD; TR1 = 1; }
unnecessary code has been deleted.
Look at the line preceding initialise_serial_com: There is a missing ";".
ohh... yes... thank you very very much..!!
You might NOT consider :
main() can not return a valus
Well, it can - but, in this case, it should not!
error 267: 'elseif': Requires ANSI-style prorotype.
while(1); does not return
Generally compilers special case the treatment of main(), assuming it returns an int, and not fussing overly in the absence of the return keyword.
The behaviour if it does return/exit depends on the startup code, but in embedded systems it not usually desirable as there is no-where for the exit code to be propagated too, and the system will either crash, lock, reset, or fail in some manner.