building a c program

Status
Not open for further replies.

seamusmcd

New Member
how can i build my c program which includes a few of my own header files without going back and compiling all of my header files seperately...... thanks
 
The include keyword lets you do what you want

#include "my_header.h"

The quotes mean that the header is in the same directory as the .c file.

#incude <header.h> means that the file is in a central library folder.
 
These are my header files:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include "rand.h"
#include "alloc.h"
#include "blockio.h"
#include "open.h"
#include "mod2sparse.h"
#include "mod2dense.h"
#include "mod2convert.h"
#include "rcode.h"
#include "enc.h"

everytime i restart the main program i have to recompile each header file individually. is there anyway i can compile my main file without having to go back and compiling all the header files.
 
This sounds like an issue with your development environment. You shoudn't have to compile the .h files. They should get compiled as though they were inserted into file they are included in.

If you give a bit more info it would help.
 
If there's actual code in those file, make them into libraries, or simply put them in a different source file and reference them, leave only defines inside the header files.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…