warning: statement has no effect

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dissectcode
    New Member
    • Jul 2008
    • 66

    warning: statement has no effect

    Hello - I am trying to eliminate warnings in my code...and have a question...

    I have a function
    Code:
    void function_name(void)
    {
      functionA();
    }
    which goes to a file that says:

    Code:
    #define functionA()   functionB()
    which finally goes to:

    Code:
    #define functionB() (0)
    I need to keep these macro definitions there, but it obviously doesn't do anything right now. What can I put in this code to supress that warning??

    Thanks!
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Well you could put in a ; instead of (0) but then you couldn't use functionA in an expression. It partly depends on what the nominal return type of functionA is supposed to be.

    Comment

    • dissectcode
      New Member
      • Jul 2008
      • 66

      #3
      Thanks for the response... I tried putting a ; instead of (0) but the warning did not go away. What can I do?

      Thanks!

      Comment

      • oler1s
        Recognized Expert Contributor
        • Aug 2007
        • 671

        #4
        In Visual C++, for example, I would have followed the advice at http://msdn.microsoft.com/en-us/library/2c8f766e.aspx. (Specifically, I would have used the push/pop mechanism indicated at the bottom of the page.)

        It depends on the compiler to try and disable the warning.

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Most (if not all) compilers keep their mouth shut if a value is cast to a void; as in:

          [code=c]
          (void)functionA ();
          [/code]

          kind regards,

          Jos

          Comment

          Working...