2 ms·
On the "no formal parameters function" - You can forward declare the function with the parameter list, and then define the function without a parameter list. Th
by justinlloyd 4y ago
On the "no formal parameters function" - You can forward declare the function with the parameter list, and then define the function without a parameter list. This should (might) generate a compiler error/warning in very old compilers, but really it is an indicator that you are trying to use an older style of declaration with "modern" convention.
If you have a forward declare you can then bring in different headers (or use a pre-processor block) depending on need that will redefine the function.
The reason this ability exists, in all the different incantations you can use, is to ensure that very old-style C will still compile.
You could also pop things off the stack manually inside a function all the time, even without a paramter list, popping off an "invisible" parameter also let you do things like return to a different part of the code than the invoking function.
The compiler I worked on in 1985-ish supported forward declarations, which was "fancy and new" at the time.
Insert obligatory, "I was there Gandalf, 3,000 years ago."