Hiyas, I am wondering what exactly does go into a header file?
From Wiki and a number of other pages (and assignments), I know programmers can break up larger programs into separate routines and such, and at the end everything can be put together to make the "master" program work
From my understanding just function prototypes go into it, is that really true?
For example,
Is that the jest of it or is there something major I am missing?Code:In blahOther.c (library of functions) //proper headers struct node { void* data; struct node *left; struct node *right; } typedef struct node tree; int add(int a, int b) { return (a+b); } In blahTest.h #ifndef BLAHTEST #define BLAHTEST extern //do I need to include the struct?????? /* adds two numbers */ extern int add(int a, int b); #endif /* blahtest_h */ In blahTest.c (contains main) #include "blahTest.h" ... int triple(int x) { return x*add(a,b); }
Also if I am correct, and in my library of functions file (blahOther.c) I had some structs, specifically a binary tree (NOT BST), would I need to provide the blahText.h the typedefs for those structs?
The whole purpose of my blahTest.c is just to test my library of functions.
Of course all this is considering, that I am compiling the following way.
gcc -c blah.c
gcc -c blahTest.c
gcc blah.o blahTest.o -o test



LinkBack URL
About LinkBacks


