Question about Structs and Scope


I’m an experienced Pascal / Delphi for more than two decades and am branching out into other languages and have this question about scope. I wonder what it is about the following code that requires void calc() to be declared outside of int main()?

The narrower the scope the better, so I thought one could place the void calc() inside of int main(), but it throws a compiler error in Code Blocks without debug info. I’m not seeing what it is that becomes invisible to the compiler as undefined (that’s my assumption). Delphi is a strongly typed language with everything declared for the most part up front. Only in a few circumstances is it even necessary to use forward declarations to point to declarations not yet defined to the parser. Thanks for any responses.