Connecting Tech Pros Worldwide Forums | Help | Site Map

warning: function is not a prototype

Member
 
Join Date: Jul 2008
Posts: 62
#1: Jul 18 '08
Hello - I have another warning coming from my code and I honestly don't know why it's complaining.

I have a simple file
Expand|Select|Wrap|Line Numbers
  1. #include header.h
  2.  
  3. void function1()
  4. {
  5.   does something;
  6. }
  7.  
  8. void function2()
  9. {
  10. }
  11.  
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?

Moderator
 
Join Date: Mar 2007
Location: North Bend Washington USA
Posts: 5,370
#2: Jul 21 '08

re: warning: function is not a prototype


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++.
Reply