|
Re: .h vs .c
[Re: DLively]
#450395
04/13/15 18:36
04/13/15 18:36
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
As far as I know, they are used for different purposes (.c and .h). Here, I've found this over the internet (about libraries and headers): Think of both like this (Disclaimer: this is a really high-level analogy .. The header is a phone number you can call, while... ...the library is the actual person you can reach there! It's the fundamental difference between "interface" and "implementation"; the interface (header) tells you how to call some functionality (without knowing how it works), while the implementation (library) is the actual functionality. As far as I know, header file could help you to avoid 'undeclared function' issues, if you use function which is placed under the one that calls it, f.e.:
void callFunction(){
makeBeep();
}
void makeBeep(){
beep();
}
You can declare that 'makeBeep()' in the header file, so the whole .c file will 'know' the list of available functions (variables etc). I might be wrong, but this is how I see it so far. Best regards
|
|
|
Re: .h vs .c
[Re: FBL]
#450562
04/17/15 15:31
04/17/15 15:31
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
Okay, I've had to read this thread once or twice and find a couple examples along with these to clear things up a bit further but its starting to make sense now. Thanks for clearing this up, guys
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|