You are calling menu() before/above the point where you define it. You either need to have a function prototype at the top of the file or else move the definition of menu() above your main() function.
int menu(void); // <-- function prototype, tells the compiler how to call menu()
int main()
{
pspDebugScreenInit();
SetupCallbacks();
int choice;
choice = menu();
sceKernelSleepThread();
return 0;
}
int menu(void)
{
// ...
return 0;
}
The "implicit declaration" warning means that you have called a function without first defining its calling convention, so the C compiler has implicitly assumed that it knows how to call the function. In your case, you get lucky because the assumption is that the function takes no parameters (void) and returns an integer. In C++, implicit declarations are not allowed.
Last edited by Dr. Vegetable on Thu Feb 23, 2006 1:57 am, edited 1 time in total.
Dr. Vegetable wrote:You are calling menu() before/above the point where you define it. You either need to have a function prototype at the top of the file or else move the definition of menu() above your main() function.
int menu(void); // <-- function prototype, tells the compiler how to call menu()
int main()
{
pspDebugScreenInit();
SetupCallbacks();
int choice;
choice = menu();
sceKernelSleepThread();
return 0;
}
int menu(void)
{
// ...
return 0;
}
move function int menu() above int main()
using function prototypes is not really common
nowadays ... its old K&R style but any modern
compiler should still compile your program
just fine ... and there is no need for prototypes
anymore ...unless you really is your style to
have functions on after main
move function int menu() above int main()
using function prototypes is not really common
nowadays ... its old K&R style but any modern
compiler should still compile your program
just fine ... and there is no need for prototypes
anymore ...unless you really is your style to
have functions on after main
You may notice that I suggested both approaches. Which coding style to use is largely a matter of personal preference, but in a larger project it can be very difficult (and counter-intuitive) to try to order all of your functions top-down so that no prototypes are ever needed. If you always define a prototype for every function, you never need to worry about this.
My personal preference is to avoid prototypes during development of static local functions, and to always use them for any global functions. But once the design of my local functions has stabilized, I usually extract prototypes to the top of the file anyway. I find this practice makes it easier to harvest the code for re-use in other projects, because you can scan a list of function prototypes more easily than you can scan an entire source file to see what functionality is available for the borrowing.