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

Any way to remove unreferenced parameter warnings?

We have a design that uses function pointers and sometimes the parameters passed to a "C" routine are not used. Thus we get alot of compiler warnings. Is there any way to remove these warnings? Previous versions of the compiler did not raise these warnings.

Parents
  • This is an eternal problem - especially in the type of situation you describe.

    There are various tricks, none of which is universally applicable to all compilers. :-(

    eg

    void fn( int unused1, unused2 )
    {
       unused1; // dummy reference to unused1
    
       unused2 = unused2; // dummy reference to unused2
    
    }
    Trouble is, some compilers will give warnings like "code with no effect" on these type of tricks!

    What we need is a #pragma to tell the compiler that a parameter is deliberately unused.
    The compiler would then generate an error if a parameter marked as "unused" was actually used!

Reply
  • This is an eternal problem - especially in the type of situation you describe.

    There are various tricks, none of which is universally applicable to all compilers. :-(

    eg

    void fn( int unused1, unused2 )
    {
       unused1; // dummy reference to unused1
    
       unused2 = unused2; // dummy reference to unused2
    
    }
    Trouble is, some compilers will give warnings like "code with no effect" on these type of tricks!

    What we need is a #pragma to tell the compiler that a parameter is deliberately unused.
    The compiler would then generate an error if a parameter marked as "unused" was actually used!

Children