This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is there a way to suspend warning C280 ?

The following warnings apears from time to time.

MEM_TST.C(41): warning C280: 'mem_DPP': unreferenced local variable


Sometimes I want to suspend them, but I can't find how.
suspend linker warnings, Lxxx, are possible via the project configuration screens but I didn't see any place to direct the compiler to suspend compilation warnings Cxxx.

Is it possible at all ?

I am using the following environment:
IDE-Version:
µVision2 V2.40
Tool Version Numbers:
Toolchain Path: C:\Keil\C51\BIN\
C Compiler: C51.Exe V7.10
Assembler: A51.Exe V7.09
Linker/Locator: BL51.Exe V5.03
Librarian: LIB51.Exe V4.24
Hex Converter: OH51.Exe V2.6
CPU DLL: S8051.DLL V2.43
Dialog DLL: DCORE51.DLL V2.43
Target DLL: BIN\DCD_DoCD.DLL V1.06
Dialog DLL: TP51.DLL V2.43

Thanks.
Amit A.

Parents
  • "Suspending" warnings is almost invariably the wrong thing to do. Fix the code so there's no reason for the warning to appear, instead. For the warning under consideration, that means to simply remove the superfluous variable (or enclose it in the same #if conditions that disabled the code using it).

Reply
  • "Suspending" warnings is almost invariably the wrong thing to do. Fix the code so there's no reason for the warning to appear, instead. For the warning under consideration, that means to simply remove the superfluous variable (or enclose it in the same #if conditions that disabled the code using it).

Children
  • "Just use a dummy assignment."

    This works in Keil, but in some other compilers it would give you another warning like "Code has no effect" or similar!

  • "'Suspending' warnings is almost invariably the wrong thing to do. Fix the code so there's no reason for the warning to appear, instead."

    Definitely!

    "For the warning under consideration, that means to simply remove the superfluous variable"

    Unfortunately, the Keil compiler also gives this warning for unused function parameters.
    There may be reasons why the function needs to conform to a certain set of parameters in this particular application (eg, a common API format).
    Therefore, it would be helpful if the message distinguished between unused parameters and unused local variables.

    This is a very common problem, and "workarounds" that work in one compiler may not in others; eg, as I mentioned before, the "dummy reference" works for Keil but gives another warning in some other compilers!

    Some compilers have a #pragma to specifically mark a parameter as "unused".

  • This is a very common problem, and "workarounds" that work in one compiler may not in others;

    In my own experience, a pretty universally applical idiom is

         (void) parameter;   /* Explain why... */
    

    I've yet to see any compiler warn me about that one.

  • "I've yet to see any compiler warn me about that one."

    Yes, I have seen a "Code has no effect" warning for that!

    I forget exactly what compiler it was - something VAX-based for a Hitachi version of the Motorola HC05, or something...?

  • But sometimes, when you write code, you create an infrastructure, that still in this early stage doesn't use all variables that where declared (in function's prototype or in the functions as well).
    in such a case when you compiles, you want to disable all the known warnings, in order to see the real warnings only.

    For this reason, you need to be able to set a flag in the compiler page at the project definitions (not in the code!), that will tell the compiler to ignore these specific warnings.

    The problem with all the mentioed above workarounds is that they can be left in the code and forgotten there forever - this is bad programming !

    By setting an external flag, and clearing it before makeing a SW realese, you can clean your code, and still work in a way that will allow you faster handle of the real warnings at the relevant time.

    I founf the disable warning L16 preaty usefull, and to my opinion all warnings (both of comiler and linker) should have the option to be disabled from the project definitions.

  • still in this early stage
    see the real warnings only

    You work with conflicting objectives. A piece of code can either be in early prototype state, or it can be important to have it compile warning-free. Asking for both of these at the same time is, mildly put, a waste of effort.

  • "The problem with all the mentioed above workarounds is that they can be left in the code and forgotten there forever"

    Equally, they could be left in the Project options (or makefile, or whatever) and forgotten there forever...!

    That's life!

    At least if they're in the source code you can easily document them with some standard comment; eg,

    unused = unused; // HACK! Temporarily suspend warning
    The you do a global search on the entire project source looking for "HACK!"

    In the end, it all just comes down to discipline!