Hello,
I encountered a problem when I tried to write a program in GNU C, which allows nested (local) functions to be used. I wasn't able to make a forward declaration to work. The problem is illustrated with the following short program
Code:
// GNU c program demonstrating problem with forward declarations
// of nested functions.
// Compiler produces error "static-declaration follows non-static
//declaration";
// when I place the keyword "static" in front of "void Inner2();", I still
// get an error
// Program was tested on gcc (Debian 8.3.0-6) as well as on
// gcc (Rev2, Built by MSYS2 project) 9.2.0
#include<stdio.h>
void Outer(){
void Inner2(); // "non-static declaration"
void Inner1(){
Inner2();
}
void Inner2(){ // "static-declaration"
printf("%s","Hello World!");
}
Inner1();
}
int main(){
Outer();
}
I would appreciate any information how to make forward declarations of nested functions work.
Regards,
bostjanv