The Keil prompt is: Missing '; 'before' XXX', but the semicolon is missing!

Source: Internet
Author: User

Today, I wrote a 51 program. during compilation, Keil always prompts that a semicolon was lost, but I couldn't find out where the semicolon was lost. It took me one afternoon to solve the problem, share your experience here to prevent others from making the same mistake! The prompt message is:

Lcd12864.h (20): Error c129: Missing '; 'before' flag'

The u8 flag I defined in the lcd12864.c file is 0;

Make this statement in the lcd12864.h file: extern u8 flag;

Because the problem lies in the header file, the code in the lcd12864.h file is listed as follows:

# Ifndef _ lcd12864_h
# DEFINE _ lcd12864_h
# Include <reg52.h>
Extern u8 flag;

An error occurs after compilation. Double-click the error message. The arrow will jump to the extern u8 flag!

But let's take a look: This sentence does not contain semicolons at all (of course, there are no semicolons in the statements before and after it ).

The actual problem lies in the u8 In the extern u8 flag! Change the above Code to the following:

# Ifndef _ lcd12864_h
# DEFINE _ lcd12864_h
# Include <reg52.h>

# Define u8 unsigned char
# Define 2010unsigned int
Extern u8 flag;

Haha, you don't have to explain the reason. But in this case, why does the compiler prompt that the semicolon is missing? I don't understand it. Which of the following experts will be troubled to explain the mysteries!

In addition, in order to list the situations that cause such errors more comprehensively (it is easy to find out where the problem is located and not to list it), I will also list the situations encountered by other online users:

 

Link to the following article: http://weidebao1985.blog.163.com/blog/static/20368906200971405819673/

Two strange errors about Keil

Today, I checked the program and found two abnormal errors in Keil ., Summary

Question 1:During compilation, the system always prompts that a line lacks a semicolon or contains invalid characters. However, on the surface, it seems that there are no abnormal symbols and the semicolon is also entered in the English mode. Alas, I can't see it with the naked eye. Now I want to teach you a trick: comment out the wrong line with the double slash, in this way, you can see that this line may have some chaotic characters that you accidentally entered at the time, delete the chaotic characters, and finally remove the annotator. Everything is OK, this vulnerability is really useful for Keil;

Question 2:During compilation, the system always prompts a syntax error. On the surface, there seems to be nothing, so I wrote a simple array? What's the problem? The problem is that the array name is Da.Ta [5]. If you change a name, no error is returned. It seems that you cannot use da when writing a program in C language in Keil.Ta name. It's tough. Remember to remember it.

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.