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
  • I recommend defining a macro so that you can change implementation as needed between compiler versions or different platforms.


    #define UNUSED(arg)  if(arg){}
    
    void f (int a)
        {
        UNUSED(a);
        }
    

    (Note there's another implementation option shown. The idea is to find some syntactically legal statement with no side effects that will get optimized out, yet not produce any compiler or lint warnings.)

    Some compilers will stop complaining if you don't name the unused arguments:

    void f (int a, int /*b*/)
        {
        }
    

Reply
  • I recommend defining a macro so that you can change implementation as needed between compiler versions or different platforms.


    #define UNUSED(arg)  if(arg){}
    
    void f (int a)
        {
        UNUSED(a);
        }
    

    (Note there's another implementation option shown. The idea is to find some syntactically legal statement with no side effects that will get optimized out, yet not produce any compiler or lint warnings.)

    Some compilers will stop complaining if you don't name the unused arguments:

    void f (int a, int /*b*/)
        {
        }
    

Children
No data