This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/51515] New: Unable to forward declare nested functions
- From: "elbacon at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 12 Dec 2011 14:56:47 +0000
- Subject: [Bug c/51515] New: Unable to forward declare nested functions
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51515
Bug #: 51515
Summary: Unable to forward declare nested functions
Classification: Unclassified
Product: gcc
Version: 4.6.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: elbacon@gmail.com
Attempting to forward-declare a nested function results in a compiler error.
This used to work in gcc-3.4.
eg
void f()
{
void g(void);
g();
void g() {}
}
compiling this produces the following errors:
cc -c -o tfn.o tfn.c
tfn.c: In function âfâ:
tfn.c:5: error: static declaration of âgâ follows non-static declaration
tfn.c:3: note: previous declaration of âgâ was here
applying 'static' to the function declaration or definition, which is what the
error message might suggest the compiler wants, produces:
void f()
{
static void g(void);
g();
static void g(){};
}
cc -c -o tfn.o tfn.c
tfn.c: In function âfâ:
tfn.c:3: error: invalid storage class for function âgâ
tfn.c:5: error: invalid storage class for function âgâ
tfn.c:5: warning: conflicting types for âgâ
tfn.c:5: error: static declaration of âgâ follows non-static declaration
tfn.c:4: note: previous implicit declaration of âgâ was here