Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by k_ivan. 04/25/26 19:13
ZorroGPT
by TipmyPip. 04/25/26 16:09
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
400 free seamless texture pack downl. here !
by NeoDumont. 04/08/26 19:55
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (AndrewAMD, Grant, valino), 3,361 guests, and 13 spiders.
Key: Admin, Global Mod, Mod
Newest Members
valino, juergenwue, VladMak, Geir, ondrej
19209 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Organizing All Your Files In A Project [Re: Mahonroy] #394076
02/09/12 19:59
02/09/12 19:59
Joined: Sep 2003
Posts: 353
Mahonroy Offline OP
Senior Member
Mahonroy  Offline OP
Senior Member

Joined: Sep 2003
Posts: 353
Ok so I have one main.c file, multiple .c files. Each .c file has a corresponding .h file. Every .c file and .h file has a ifndef statement at the top, and an endif at the bottom (so it doesn't get defined multiple times). All of the .c files have an include of their equivalent .h file at the top (right underneith the ifndef stuff), and every .h file has an include of its corresponding .c file at the bottom (right above the endif). The .c files contain the actual functions, and the .h files contain the coresponding function prototypes, as well as some variables. The .h files also contain some #define things, that the functions use. Other .c files need to use some of these #define's though too, and this is where I am running into problems... because the other functions cannot see them.
An example... lets say I have mystuffA.c, mystuffA.h, mystuffB.c, and mystuffB.h. So mystuffA.c needs to use #defines from mystuffB.h, and mystuffB.c needs to use some #defines out of mystuffA.h
In the main.c file, at the top, I am only including all of the .h files. To get all my stuff to compile, I had to pull some of those #define statements out of the .h files, and put them in the main.c file, above all of the .h includes.

Last edited by Mahonroy; 02/09/12 20:03.

NATIO Released! Check it out at http://mahonroy.home.comcast.net/natio.htm -Matt AMD 1.2 Ghz Thunderbird 512 Meg Ram GeForce 2 Ultra 64 Meg DDR Using A5 Professional
Re: Organizing All Your Files In A Project [Re: Mahonroy] #394101
02/10/12 01:00
02/10/12 01:00
Joined: Sep 2003
Posts: 353
Mahonroy Offline OP
Senior Member
Mahonroy  Offline OP
Senior Member

Joined: Sep 2003
Posts: 353
So I'm assuming I need to make a definitions.h file, and include this at the top of my main.c then?


NATIO Released! Check it out at http://mahonroy.home.comcast.net/natio.htm -Matt AMD 1.2 Ghz Thunderbird 512 Meg Ram GeForce 2 Ultra 64 Meg DDR Using A5 Professional
Re: Organizing All Your Files In A Project [Re: Mahonroy] #394119
02/10/12 10:14
02/10/12 10:14
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
No, just include "myStuffB.h" in "myStuffA.c" right under the include of "myStuffA.h"...

Code:
#ifndef myStuffA_c
#define myStuffA_c

#include "myStuffA.h"
#include "myStuffB.h"

//...

#endif /* myStuffA_c */



That is what I meant with "a .c file includes everything it needs" smile

Re: Organizing All Your Files In A Project [Re: HeelX] #394284
02/11/12 16:45
02/11/12 16:45
Joined: Sep 2003
Posts: 353
Mahonroy Offline OP
Senior Member
Mahonroy  Offline OP
Senior Member

Joined: Sep 2003
Posts: 353
Ok I got ya now. After I included only the header files that were needed everything works perfectly now, thanks!


NATIO Released! Check it out at http://mahonroy.home.comcast.net/natio.htm -Matt AMD 1.2 Ghz Thunderbird 512 Meg Ram GeForce 2 Ultra 64 Meg DDR Using A5 Professional
Page 2 of 2 1 2

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1