forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

warnning main is normally a non-static function cant comply?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Mon Jan 23, 2006 6:08 am    Post subject: warnning main is normally a non-static function cant comply? Reply with quote

thats what i get whyen trying to comply,

warning: 160: main is normally a non-statick function

warning: 167: control reaches end of non-void function

i fixed up my game and put a repeat in it by making everything that was in the main, one big function, now i call the function in the loop but it gives me those 2 errors, heres my code (main())

Code:
int main() {
   restart();
   sceKernelSleepThread();
   return 0;
}
}
}
}


i have to have all those '}' or else i get a syntax error, and because i ahve several loops in the function
Back to top
View user's profile Send private message
Dr. Vegetable



Joined: 14 Nov 2005
Posts: 171
Location: Boston, Massachusetts

PostPosted: Mon Jan 23, 2006 6:19 am    Post subject: Reply with quote

Although you didn't post enough code for anyone to be sure, it sounds like you have the closing brackets '}' for the loops in your main() routine, and the open brackets '{' for the loops inside of your restart() function. You cannot do this. You must end the loops inside the function, so move the extra brackets there.

I'm guessing your code looks something like this:
Code:

void restart()
{
   while (dontEndTheGame)
   {
      // Play the game...
}

int main()
{
   } /* end while loop */
}


When you moved the loop into the function, you should copy the brackets:

Code:

void restart()
{
   while (dontEndTheGame)
   {
      // Play the game...
   } /* end while loop */
}

int main()
{
}


If you still have problems, you should post the code for your whole program to get better advice. Hope this helps!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Mon Jan 23, 2006 8:09 am    Post subject: Reply with quote

thanks it helps, im gonna og to test it now, all i had before was 3 loops, one for hte start menu kind of thing, 1 in the middle for playing the game, and one at the end displaying either end game game over , etc. but ya if it still doesnt work ill put all my code seeing as how my game is already a beta nd its up on intenet
Back to top
View user's profile Send private message
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Mon Jan 23, 2006 8:23 am    Post subject: Reply with quote

ok i cant get it, whats the difference between int and void?

i took donw my code because i think ig ot it and its a waste of space wiht a huge thing of code right h=there soi ill repost it if i have any problems


Last edited by sg57 on Mon Jan 23, 2006 8:48 am; edited 2 times in total
Back to top
View user's profile Send private message
ReKleSS



Joined: 18 Jun 2005
Posts: 73
Location: Melbourne, Australia

PostPosted: Mon Jan 23, 2006 8:35 am    Post subject: Reply with quote

Get an editor with auto indenting or something - or use indent. For some reason your main function is inside the repeat() function (which should have been obvious from all the }'s down the bottom)... I'm guessing you were seeing errors about unclosed brackets, and just stuck them down the bottom.

By the looks of it, those two extra }'s from the bottom should go just above main().

Int and void? int is an integer value, void is nothing. The proper definition of main is
Code:
int main(int argc, char *argv);

but just int main() or void main() should be fine.
-ReK
Back to top
View user's profile Send private message
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Mon Jan 23, 2006 8:41 am    Post subject: Reply with quote

Dr. Vegetable wrote:
Although you didn't post enough code for anyone to be sure, it sounds like you have the closing brackets '}' for the loops in your main() routine, and the open brackets '{' for the loops inside of your restart() function. You cannot do this. You must end the loops inside the function, so move the extra brackets there.

I'm guessing your code looks something like this:
Code:

void restart()
{
   while (dontEndTheGame)
   {
      // Play the game...
}


wait, so are you saying that ithere should only be 1 { at the end of the main() { ? if so im gonna go and move the { } around see what i can do....

int main()
{
   } /* end while loop */
}


When you moved the loop into the function, you should copy the brackets:

Code:

void restart()
{
   while (dontEndTheGame)
   {
      // Play the game...
   } /* end while loop */
}

int main()
{
}


If you still have problems, you should post the code for your whole program to get better advice. Hope this helps!
Back to top
View user's profile Send private message
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Mon Jan 23, 2006 8:46 am    Post subject: Reply with quote

WAIT WAIT WAIT, it hink ig ot it, i moved all the '}'s from the end into the end of the function now i get a hole new error....ill fix it tho!
Back to top
View user's profile Send private message
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Mon Jan 23, 2006 10:21 am    Post subject: Reply with quote

ya i got it, but i think ur post was delayed or something cause i fixed it then posted about it but i didnt se urs there...weird, o well i did get it fixed, i just had to move all those closing brackets into the functions end and then fix a few more errors but i got it working, now i just need to get some sceDisplayScreenWaitVblankStart's and flipScreen();s in there to get the images to show
Back to top
View user's profile Send private message
HaQue



Joined: 25 Nov 2005
Posts: 91
Location: Adelaide, Australia

PostPosted: Mon Jan 23, 2006 11:59 am    Post subject: Reply with quote

Just to clarify a few things that may not be clear.

The "int main()" or "void main()" and the return value are linked.

so if you use "int main()", at the end of the main function you need to return an integer - return 0;

Code:
int main() {
   funct_1();
   return 0;
}


or if you use "void main()", at the end of the main function you need to return an integer - return 0;

Code:
void main() {
   funct_1();
}


see how void doesnt have a return value... also this doesnt comply with C standards, and you shouldnt do it.

The return value can be used to say if the program exited correctly. This is commonly used as 0, and if you had a check in the program somewhere that had to exit the program you could use return 1.
Code:
int main() {

   if (someValidCheck() == false) {
   return 1;
   }
   else {
   // rest of the program
   other_functs();
   }

   return 0;

} // end main


also, if it helps, use comments to show yourself where the closing brackets go. It helps for programs with lots of loops:
code with 3 seperate loops executed after each other
Code:
int main() {

for (i = 1; i <= 10; i++) {
  ...code...
} // end i loop

for (j = 1; j <= 10; j++) {
  ...code...
} // end j loop

for (k = 1; k <= 10; k++) {
  ...code...
} // end k loop

} // end main


code with 3 NESTED loops executed at the same time...
Code:
int main() {

for (i = 1; i <= 10; i++) {
  ...code...

    for (j = 1; j <= 10; j++) {
      ...code...

        for (k = 1; k <= 10; k++) {
       ...code...

       } // end k loop
   } // end j loop
} // end i loop

} // end main




BTW, the code isnt exactly right, just intended to show the things Ive mentioned. Hope it helps. (in a hurry so couldnr explain it as well as I'd have liked!!)

HaQue
_________________
www.smartwave-wireless.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Mon Jan 23, 2006 12:44 pm    Post subject: Reply with quote

n problkem that helps alot, but i have one question that in lua is a couple numbers in side of an arguemnet and its doen, but hwo do make text/pictures display for a certain amount of time?

everytime i put a number in side the sceDisplayScreenWaitVblankStart('here'), i get:

Code:
main.c:197: error: too many arguments to function 'sceDisplayWaitVblankStart'


in LUA you just plop a number in ther and walaa

but apparently its different in c/c++?

anyway, im also having touble with calling functions in the main program,

like this here:
Code:
SceCtrlData pad;
    sceCtrlReadBufferPositive(&pad, 1);
    if(pad.Buttons & PSP_CTRL_SQUARE) {
                   int scroll();
}   else if(pad.Buttons & PSP_CTRL_CROSS) {
                   void repeat();                   
}


maybe it has to do with the return 0s?i dont have any yet i see peoples with them so i guess ill try it out but help if u can please
Back to top
View user's profile Send private message
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Mon Jan 23, 2006 1:23 pm    Post subject: Reply with quote

o and the things inside the if staements are functions i defined at the top of the list, i think i have to put 'return 0;' after that line but i dont know why, probably because its 'true' that i want to run that fucntion if i press square/cross? i dunno please help
Back to top
View user's profile Send private message
HaQue



Joined: 25 Nov 2005
Posts: 91
Location: Adelaide, Australia

PostPosted: Mon Jan 23, 2006 3:19 pm    Post subject: Reply with quote

Hi,
This is not a nasty toned message, just some freindly advice...

I think you should look at some simple programming examples. none of what you are asking is really PSP specific, and you cant expect people to write your code for you.

If you spend some time grasping these basic things, your coding will be alot easier and more fullfilling than just fixing things so they work.

now:

You dont need a return() in if statements, you need 1 "return ?" statement in each function that has been coded to need one:

if you have int main() {} then you need to return an integer value at the end of the function .... "return 0;". (does NOT have to be "0"... can be whatever you need it to be!

if you have int GetSizeOfWhatever() {} then you need to return an integer value at the end of the function .... "return(size);".

if your function has the possibility of ending BEFORE you get to the end and it will miss the retrn(); at the end, you should put a return; statement at the point it will get out of that function.

hope that helps. :)


Code:

int main () {

var = getSizeOfSomething();

printToScreen("var =" + var);

return(0);

} // end main

// the getSizeOfSomething function
int getSizeOfSomething() {
int size = 25;
return(size);
} // end getSizeOfSomething


dodgy I know, but instruction code is :)
_________________
www.smartwave-wireless.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Mon Jan 23, 2006 3:29 pm    Post subject: Reply with quote

ya i understand that, ill just look around but its hard to find something simple (besides my own) that includes analog functioning and a sceDisplayScreenWaitVblankStart with arguments to answer my question
Back to top
View user's profile Send private message
HaQue



Joined: 25 Nov 2005
Posts: 91
Location: Adelaide, Australia

PostPosted: Mon Jan 23, 2006 5:59 pm    Post subject: Reply with quote

Hi,
post the code containing "sceDisplayScreenWaitVblankStart('here')", it would be easier to help on that part of it.

how are you putting the int in there? I havent looked but what does that function need.

Code:
are you doing sceDisplayScreenWaitVblankStart('23')

or
Code:
sceDisplayScreenWaitVblankStart(23)

_________________
www.smartwave-wireless.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
PeterM



Joined: 31 Dec 2005
Posts: 125
Location: Edinburgh, UK

PostPosted: Mon Jan 23, 2006 6:30 pm    Post subject: Reply with quote

I really wouldn't recommend learning C or C++ programming on a PSP - try writing some small command line programs first.
Back to top
View user's profile Send private message Visit poster's website
HaQue



Joined: 25 Nov 2005
Posts: 91
Location: Adelaide, Australia

PostPosted: Mon Jan 23, 2006 9:09 pm    Post subject: Reply with quote

I was looking at your questions again... I noticed something after I posted last time.

you wrote:
Quote:
everytime i put a number in side the sceDisplayScreenWaitVblankStart('here'), i get:


Code:
main.c:197: error: too many arguments to function 'sceDisplayWaitVblankStart'


the "Screen part at the top is obviously just a typo, but the important thing is the function.

If you look at the pspdisplah.h file, it will tell you the way the functions have been defined.

in the case of sceDisplayWaitVblankStart() it is:

Code:

/**
 * Wait for vertical blank
 */
int sceDisplayWaitVblankStart(void);

so it doesnt actually take any integers. you simply call:

sceDisplayWaitVblankStart();

do a text search for sceDisplayWaitVblankStart in the folder of the pspsdk and you will see many examples of "main.c"

Cheers,

HaQue[/code]
_________________
www.smartwave-wireless.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sandberg



Joined: 05 Oct 2005
Posts: 90
Location: Denmark

PostPosted: Tue Jan 24, 2006 1:55 am    Post subject: Reply with quote

You can find two free books which'll teach you more or less anything about C++ from the link below.

http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html
_________________
Br, Sandberg
Back to top
View user's profile Send private message
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Tue Jan 24, 2006 6:28 am    Post subject: Reply with quote

ok that helps. ill just look around the pspdev folder, so

im also looking for an analog usage program/game with soruce code so i can learn how to use hte analog a bit better, all i know is pad.lx and pad.ly so please help
Back to top
View user's profile Send private message
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Tue Jan 24, 2006 6:31 am    Post subject: Reply with quote

P>S> im on the schools computers right now, good thing thye dont bock forums.ps2dev.org lol

anyways, i just need some souyrce code that includes all the basic functions and things that i could learn alot from, so ill just look around, but if i get a SERIOUS problem meaning an error that is invisible or something or cygwin messses u, then ill ome back and ask some questions
Back to top
View user's profile Send private message
HaQue



Joined: 25 Nov 2005
Posts: 91
Location: Adelaide, Australia

PostPosted: Tue Jan 24, 2006 10:00 am    Post subject: Reply with quote

just getting source code and nailing it together to get what you want working is not a very good idea. you won't grasp the basics and will actually take longer to learn.

You also will be dealing with many programming styles of all the authors of the code you use and alot of them will have bad programming style that you could pickup.

While theres nothing wrong with using others source code (dont re-invent the wheel) You should try programming a few things from scratch and get to learn the basics first.

This is the knowledge that will help you fix programming errors quickly.

I know it is hard when you start out because you just want to program stuff and not do hello world's and the like. It does take a bit of time, and Im sure alot of people try for a few days and just forget it. It is worth the extra time.

Its like wanting to bake cakes. You buy the "packet mix" of 10 different brands and make 10 nice cakes. You still don't know how to make cakes though.

HaQue
_________________
www.smartwave-wireless.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Tue Jan 24, 2006 10:15 am    Post subject: Reply with quote

well if you go to www.pspupdates.com, youll see that i made one of my own little games called stopper 69 and i made it from 1/2 scratch, the other the lesson with the timer, but i kno how to make a timer and such, im just working with functions and trying to get what i want to happen, happen, i just dont know some of the basic rules, like hte return 0, but now i understand it after reading this, now i just need to kno what arguments can be held in the sceDsiplayScreenWait('here'), so i cna have a 10 second pause(600 vblanks), just need to find out how some things work,but now that i kno i can look in the pspdev folder for the function examples and such, i should ahve no problems

for example, i just looked in the 'include' fodler and saw a math.h so i pen ed it up and i found that 'M_PI' is wha is needed to print out or use pi.
Back to top
View user's profile Send private message
HaQue



Joined: 25 Nov 2005
Posts: 91
Location: Adelaide, Australia

PostPosted: Tue Jan 24, 2006 11:14 am    Post subject: Reply with quote

cool, it really sounds like you are going ok with it all. I would still try and pickup as much of the basics as you can. Good Luck with it all too.

BTW, couldnt find Stopper 69 on the site. I was interested to see what sort of game and check it out.
*EDIT* found the file...

HaQue
_________________
www.smartwave-wireless.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Tue Jan 24, 2006 12:52 pm    Post subject: Reply with quote

ya theres a major bug in it im gonna fix that perfect just to get even more experience, ill make a function thatll repeat the entire program back to the start, (got it done) put a sceDisplayScreenWait(); to make hte 'WINNER' stay when you stop on 69 (that was the major bug, orese it just flashed the Winner sign and thne keeps counting) and for some reason i have this scrolling of my text, so i put it into a functiuon and ill have SQUARE load the scrolling demo and X load the main progmra(stopper 69), im just havintg this one problemn with my functions if any one could answer them, and no im not asking for code, im just aksing how to fix loading my fucntion, ok this is what happens...

i have text appear as a main menu sorta, and if you press square, you load hte scrolling demo, and cross for the stoipper 69 game, now both of these functions work but only for like a second and thast right at the beginning when its loading still (meaning if the orange light is blinking when laoding and you hold/press square/cross, itll do that function) but not any other time, i have the text in a loop so that when i load my function, its in a loop, but i cant seem to get my functins to load no matter when on the main screen, but ill keep trying and i dont want to request for code orelse i wont learn like HaQue said, im just asking for advice on how to get my functions to load for ever instead of just when its loading up the entire program..

thanks HaQue
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group