Pelles C forum

Pelles C => Bug reports => Topic started by: GuF on May 19, 2006, 08:39:10 PM

Title: Redeclaration, error #2120
Post by: GuF on May 19, 2006, 08:39:10 PM
Pelles C 4.0 doesn't compile this (redeclaration, error #2120):


int a() {
void b();
}

static void b() {
}


Thanx, if you could have a look on this!
Title: Redeclaration, error #2120
Post by: DMac on May 19, 2006, 08:54:26 PM
You have reversed the proper order try this:

static void b() {
}

int a() {
  void b();
}

or use a prototype for void b()

also you do not need to prepend keyword "void" to b when you are calling it from within a.

int a() {
  b();
}

-DMac
Title: Redeclaration, error #2120
Post by: Synfire on May 19, 2006, 09:02:51 PM

int a() {
  void b();
}

static void b() {
}


That's because you are prototyping the b() function twice. If you wish to typecast, you must encapsulate the cast in parethesis like so


#include <stdio.h>

static void b ( void );
int a ( void );

int a() {
  (void) b();
  return ( 0 );
}

static void b() {
}

int main () { return ( a ( ) ); }


To note another possible error, in you code you define a() as an int but don't return anything. None the less, the code above compiles without a hitch as a console app.

Regards,
Bryant Keller