NO

Author Topic: Old-style function declaration: warning #2027: Missing prototype for  (Read 5147 times)

iZzz32

  • Guest
Fresh Pelles C, console project, default settings. A code:
Code: [Select]
#include <stdio.h>
int xyzzy()
{
  return 0;
}

int main(void)
{
  xyzzy();
  return 0;
}
produces the following error message:
Code: [Select]
Building test.obj.
pellesc650-test\test.c(4): warning #2027: Missing prototype for 'xyzzy'.
*** Error code: 1 ***
Is it ok?
« Last Edit: October 17, 2010, 11:59:07 AM by iZzz32 »

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Variadic functions: warning #2027: Missing prototype for
« Reply #1 on: October 17, 2010, 01:11:46 AM »
Code: [Select]
#include <stdio.h>
int xyzzy(void,...)
{
  return 0;
}

int main(void)
{
  xyzzy(1);
  return 0;
}

The above should be OK, if you really need variable arguments.
---
Stefan

Proud member of the UltraDefrag Development Team

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Old-style function declaration: warning #2027: Missing prototype for
« Reply #2 on: October 22, 2010, 08:31:24 PM »
Code: [Select]
func() In C++ this means the function takes no arguments, in C it means the function takes any number of arguments. The message could probably be clearer, but it was already available and is good enough...
/Pelle