KEIL C51 shielding warning method


foreword

说明一下,这里是屏蔽警告,不是消除警告。目前我所知道的屏蔽警告的方式有四种,如果所说有什么问题或者还有其它的方式,麻烦在评论区@一下我。


1. The purpose of shielding warnings

  1. I have obsessive-compulsive disorder, and I can't stand too many warnings when compiling.
  2. The existence of some warnings has no effect on the normal operation of the program, and too many warnings make it easier to ignore some important information. Therefore, you can choose to ignore such unimportant information. The warnings that I directly block are listed below (only remember this one for the time being).

//Function definition has never been called warning
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS

2. Shielding method

1. Switch linker

1) Menu bar -> Project -> Options for Target 'Target 1' -> Device, check "Use Extended Linker(LX51)..." 2)
insert image description here
Select "LX51 Misc", write " REMOVE UNUSED”
insert image description here

2. Set the compiler to ignore warnings (recommended)

(Take warning 16 as an example)
1) Menu bar -> Project -> Options for Target 'Target 1'
2) Select "BL51 Misc", and write the alarm number to be blocked in the "Disable Warning Numbers" input box.
insert image description here

3. Using preprocessing directives

I saw an article saying that some specific warnings can be blocked by preprocessing instructions, that is, using "#pramga ...", which was used when learning C, but it was not successful in KEIL. Here is the link to the original text.

https://blog.csdn.net/weixin_42747691/article/details/108534953

4. Select the warning level

This shielding method is still from the link above, but the shielding method is a bit different, which may be caused by different versions. In addition, the higher the warning level, the more warnings can be detected. Selecting "Warninglevel 0 (disable)" will block all warnings.

I personally think that some warnings are still necessary, so it is best not to use this method, it is only issued to avoid pitfalls.

Menu bar -> Project -> Options for Target 'Target 1 ' -> C51 -> Warning
insert image description here

Guess you like

Origin blog.csdn.net/m0_54346266/article/details/128561322