Calling functions from another source file, help please

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
sg57
Posts: 144
Joined: Fri Oct 14, 2005 2:26 pm

Calling functions from another source file, help please

Post by sg57 »

ok, i have all my functions listed in a c source file called game.c and my main program in main.c, i have #included my game.c, i have made a header file but dont kno what to put in it hres what i put

Code: Select all

#ifndef GAME_H
#define GAME_H

int game();

#endif
in my game.c i have the function game(),

now when i call them from my main.c program, it doesnt give me an error but it does give me a blck screen when i try to run them on my psp nad hten 5 seconds later my psp shuts off, so could someone help me out here? o and also, i added game.o to the makefile
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

You've probably got it right, but the reason it's doing that is because something you did in game() is crashing/locking up the PSP and the watchdog is shutting it down.

Jim
HaQue
Posts: 91
Joined: Fri Nov 25, 2005 8:52 am
Location: Adelaide, Australia
Contact:

Post by HaQue »

I think it should be:

in game.c :

Code: Select all

#include game.h
in main.c:

Code: Select all

#include game.h
or

in main.c :

Code: Select all

#include game.c
in game.c :

Code: Select all

#include game.h
oh and game.o to the makefile, as you said, in both instances.

otherwise, post the main and game files (just the includes part)...

let us know the outcome, this would help others as well.

HaQue
sg57
Posts: 144
Joined: Fri Oct 14, 2005 2:26 pm

Post by sg57 »

HaQue thanks for your pep talk a while bakc, im seriously starting to get hings now, like at pspupdates, i learned how to make a menu with serious booleans going on, but i got it my 2nd try only because i forgot to blit the pointing image, anyway back on subject,

ok, it wasnt the game.c Jim, becuase i renamed it to main.c in another older and complied it fine with no error but i still ge thte black screen so maybe itll be that i dunno, im gonna keep trying tho and if it doesnt work ill try HaQues way

EDIT

ok i have got it working now, turned out my lucky guesing when it comes to header files and function geussing calling made it work, turns out the way i had mine the entire time worked, it was as jim said my game.c had an error but it wasnat coding error lol it was the name of thebackround so i fixed it its all cool now, atleast i now kno how to erpeat the entire game nwo thanksguyz
Post Reply