Unsure how to use diffrent things from different files.

Posted by Gtr on Sat 10 Jul 2004 01:57 PM — 4 posts, 18,963 views.

#0
Ahh, hey. I was wondering if anyone could expline to me how to use different things from different files. Like if I wanted to use things from track.c like 'int find_first_step'
and all the defines that go along with it if thats possible, but in another file, if anyone can help me out thanks.
Amended on Sat 10 Jul 2004 01:58 PM by Gtr
USA #1
It depends on if its locally defined (as in, for use only by that file) or globally (the entire mud). It its defined locally, there will be a prototype declaration at the top of the file. To make it global, delete that definition and put it in mud.h. Generally thats all there is to it. If the declaration is NOT there then it should work from other files anyways.
Canada #2
Another option is to simply put declarations at the top of the new file. If you want to be able to call find_first_step else where, you can add:
int find_first_step(whatever the arguments for it is);
This says this is what is needed, but it will reference the function in another file.

If your using global variables declared in track.c, you can reference them with the "extern" prefix:
extern int num_room;


And if you need macros in another file, you can put them in mud.h as whiteknight says, or just copy and paste into your new file. If you willbe using it in only a few places, better individual files, but if more than a few, better to put them in mud.h
Amended on Sat 10 Jul 2004 09:41 PM by Greven
#3
Hrmm I see, thanks guys.