The warning in C language is not tuned

Source: Internet
Author: User
In fact, most of the C language engineer is not warning, but if you and I like a cheap, not adjust hand uncomfortable, not adjust the heart itch, do not flirt a bit warning sleep well. So tell you a warning of flirting experience.

First of all, before flirting with warning, we have to put the error first please leave. In other words, the error is tuned first. After all the error has been put down, there is no guarantee that the program is not true. There are some bugs that do not report error. Although the bug does not affect us to flirt warning. But when you want to flirt with darling, there are outsiders watching how they will enjoy themselves.

Of course, the bug is often patched dirty (in the words of タカキさん "China has an old adage called nitpick") so the individual does not affect the normal program use of the base bug let him observe it.

Some new programmers if you do not know how to put the error this ye please leave, then I also say.

Error is usually caused by a syntax error. Common mistakes are usually misspelled (too anxious to flirt with darling, Big Brother you can not press so fast AH), there is no rating number or semicolon into a comma, of course, there are some "virgin" will also be Chinese punctuation problem error.

Of course, we often encounter some strange error, this kind of ye is the fault of the son. See if there is a problem with the Chinese path, some of the error even re-open the compiler can be good. Not really. Baidu, Google, Bing, and so on. (Google still seems to need to turn *qiang, I used to make Bing Bing, individuals have a personal habit, indeed a lot of people are using Google.) Recommended for beginners to use Baidu, beginners common error in Baidu have been the people answer rotten. After all, Google Now seems to be *qiang, and I do not like this kind of a cheap *qiang.

Then, ye, begin to solve the belt.

First flirt can delete. Sometimes a variable or function is declared and then always useless. This is a common warning, and my experience is to delete it. Even if there are variables that are known to be used for subsequent upgrades. If the necessary reservation is not fully determined, then the next version of the matter is again. Of course, if the declared function is already written but is useless, it can be collected and saved for later use, but it's OK to delete it if it doesn't matter with the program. Although my general practice is to only delete multiple declared variables without deleting the multi-declaration function.

The return value is not accepted, and the return value of some non-null functions is almost meaningless, and a successful return of 1 fails to return 0 or something. This return value can be a bit of a use if it is set in a branch. In fact, people originally wrote that function is convenient to enter the branch. So if it's not inside the branch. This value is not much use, this little prostitute limbo it. Pretending not to see.

A function that calls a header file but does not include the head file.

For example: Warning:type mismatch with previous implicit declaration

Implicit declaration of function ' * * * *

This kind of head file is included in the line.

List and call do not correspond to too few arguments for format

For example: printf ("%4d%4d", a);

This is either to fill a, just think there is a value is always show not come out, still think is a bug it? Hey

Of course, there are some of them are hand shake more dozen A, that delete Bai.

logical operators or/and do not know the range on both sides of the formula.

My habit is to put or and on both sides of the brackets, so I rarely encounter this warning, after all, encountered this and analysis of the logical relationship at the time, quite delayed, as before the good habit. Of course, if you have to keep playing monotony, I can not do it. Then you quickly close the door and your warning darling over two people world.

The operation has no meaning to the value

For example, you are declaring the int *p;

Then you are so *p++;

I think you mean not (*p) = (*p) +1;

You can see for yourself what you were trying to say.

Redefined, this is the meaning of the declaration many times. That's a good one, so you can use #ifndef to avoid this situation smartly.

If the branch or while loop cannot be executed, you define a unsigned and then an if judge if he is not negative. The deletion should be deleted.

There is also a warning is inconsistent parameter types, strengthen the type of conversion chant.

No matter how you flirt, you'd better recompile and run it one step at a time. The principle is that the process of flirting with warning does not produce error or new bugs.

Wish you single master smoothly seduce to warning darling, I go home and husband to do ashamed of things.

  • Related Article

    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.