warning: function is not a prototype

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

    warning: function is not a prototype

    Hello - I have another warning coming from my code and I honestly don't know why it's complaining.

    I have a simple file
    Code:
    #include header.h
    
    void function1()
    {
      does something;
    }
    
    void function2()
    {
    }
    Notice that function2 is empty for now, but the compiler gives me "warning: function not a prototype" for line "void function2()". I didn't think there needs to be a prototype since its not being called before it(function1 doesn't call it)...is it a problem that it's empty ??

    Thanks!

    UPDATE: I put a "void" as the explicit parameter in function2 and it got rid of the warning. Does anyone know what the reasoning behing that is?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Sounds like a bogus warning. I compiled your example code using Visual Studio.NET 2008 and got no warnings or errors.

    An empty function is OK in C++.

    Comment

    Working...