Welcome! Log In Create A New Profile

Advanced

to few arguments to function

Posted by RiderFx3 
to few arguments to function
March 31, 2011 10:31PM
Hello guy's !

I have this error of compil:

error: too few arguments to function 'test'

The function is:
int test(int argc, char **argv)
{
	device = PI_INTERNAL_SD;

	/* Initialize libfat */
	ret = fatInitDefault();
	if (ret < 0) 
	{
		printf("\n[-] FAT Error (ret = %d)\n", ret);
		goto err;
	}

	fflush(stdout);

	/* Retrieve filelist */
	ret = filelist_retrieve();
	if (ret < 0) 
	{
		printf("\n[-] File List Error (ret = %d)\n", ret);
		goto err;
	}

	/* Print filelist */
	filelist_print();
	
loop:
	/* Clear screen */
	Con_Clear();
	
	/* Print filelist */
	filelist_print();
	
	/* Controls */
	controls();
	
	goto loop;
	
err:
	/* Restart Wii */
	ISFS_Deinitialize();
	Restart_Wait();

	return 0;
}

The prototype is:
int test (int argc, char **argv);

So i don't know why I can't compil...
Re: to few arguments to function
March 31, 2011 10:44PM
The error is where you call the test function, not in the implemetation, and you haven't shown that code.
Re: to few arguments to function
April 01, 2011 02:34PM
Thanks Daid!

so what must I have to add ?



Edited 1 time(s). Last edit at 04/01/2011 02:35PM by RiderFx3.
Re: to few arguments to function
April 01, 2011 06:05PM
I don't know, because you didn't post the offending code.

The error normally looks like this:
file.h:15: error: too few arguments to function ‘int test(int argc, char** argv)’
file.c:33: error: at this point in file
Without code of the 2nd location I cannot say what you do wrong.
Re: to few arguments to function
April 02, 2011 08:31AM
.c:118:14: error: too few arguments to function 'test'
.c:58:5: note: declared here


note: declared here point to:
int test (int argc, char **argv);

thanks
Re: to few arguments to function
April 02, 2011 10:43AM
Sigh. You're not that experienced to programming right? As I said in the first reply, you didn't add the code where you call the function. I think you're better off with some basic programming tutorials before you try to program for the Wii.

Implementation:
int test()
{
  return 0;
}
Declaration:
int test();
Calling:
....
  test();
....

Basically, what you did, is you made a function called "test" that needs 2 parameters. And you call it with only 1 or even 0 parameters.



Edited 1 time(s). Last edit at 04/02/2011 10:43AM by Daid.
Re: to few arguments to function
April 02, 2011 10:45AM
If this is your entry point function - then you should be using main, your compiler looks for that word as the entry point.
int main(int argc, char **argv) 
{
...
}
(or have you found a compiler option thatchanges this?)

Since your code doe snot use the command line paramaters 'int argc, char **argv' you can just leave them out.
int main() 
{
...
}
Re: to few arguments to function
April 04, 2011 08:24PM
Thanks guys !

I'm not developer... :)

I'm trying to mod an existing homebrew. In facts, I want to add an other homebrew, IN my mod.
So I have 2 "int main". And i have renamed the other int main, and I want to call the function when I press B.

The function test need the "(int argc, char **argv)" to work ?
Re: to few arguments to function
April 05, 2011 12:31AM
Would you try to add horsepower to a car when you know nothing about engines?
Re: to few arguments to function
April 05, 2011 03:37PM
(Yeah my car is fully modded, I have learned with a friend about how modifying the power of my car, and add horse power :)
I can now repair my car without my friend.)

on the Wii, i have modded an existing homebrew, without any base in dev, and I want to understand step by step why it don't work. I don't have the time to completely learn the C langage so i try to understand the mecanism on forums like wiibrew coding.

I can understand that you don't want to help me anymore...

thanks a lot guys.
Re: to few arguments to function
April 06, 2011 12:40AM
I do want to help you. But you have to understand the basics about what you are doing. What a function call is, what parameters are. These are not difficult things, and not even limited to the C language (just about any programming language has them).

I usually recommend people to learn a different language then C to start with. But you are focused on the Wii homebrew modding, so you better stick with this because this is where you want to accomplish something.

Most likely your code will work if you change the "int test(int argc, char**)" to "int test()" but it would help you more if you understand why.
Re: to few arguments to function
April 08, 2011 11:47AM
The function int test install themes on Wii Menu.
it's the code source of mymenuify (not the GUI version)

At the origin, the "int test" is the "int main" of mymenuify, and I would integrate that than a function in another homebrew.
This function will be launched when i press B.

You know every thing ;)



Edited 1 time(s). Last edit at 04/08/2011 11:49AM by RiderFx3.
Re: to few arguments to function
April 08, 2011 08:51PM
You can not copy, rename and call the main function of another program and call it when you press B.

I would not try to "learn the mechanism but not the language" calling theming functions (guessing those are permanent changes). It seems like you are not going to get to the point of compiling any of that code soon but I'm just kindly warning you before you do.

Main functions initialize some things (such as the video, input, whatever), copying, renaming and calling the function will not work - at least - because of this. Main functions loop. You will need to understand how to get off a loop (in case you want to do so). Main functions call other functions. You will need to copy, paste, include/define those.

Look at those topics, if you've got the time. If you don't, my advice would be to stop wasting it on this and go waste it on your favorite form of entertainment.

This has been kind sarcasm :), the point is: you won't get to compile C by playing around, it is C! If you want to learn (the amount of knowledge you need depends of which programs you are trying to merge) it it will take effort/time (how much is up to each person) and you said you did not have time.

Have a good day!
Re: to few arguments to function
April 11, 2011 11:32AM
Thanks Aruskano.

I have delete all the fonctions in the second main like "draw background etc..."

I have copied and past all the "define" and "include".

I will continue in that way. Must I have to delete the "(int argc, char **argv)" and write "()" ?
Sorry, only registered users may post in this forum.

Click here to login