[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: includes and binary code



On Fri, Dec 17, 2004 at 07:24:53PM +0100, soraberri wrote:
> 
> I think my problem is a concept failure:

 yep ;-)

> When I include in my programs a #include <afile.h> I am telling the 
> compiler to look for afile.h and paste the code in my program.

Not exactly the compiler but the pre-processor.
The preprocessor does a lot more than insert the file text.
See the man page for "cpp".

I think the part you are missing is
the location of 'afile.h'.

Inside the <> there is some expectation that the file
will be found in a standard location.  Make sure
your  #include <afile.h> is correct.

i.e. Compare and contrast:
     #include <afile.h>
     #include "afile.h"
     #include "../headers/afile.h"

I like to think of 'cc' or 'gcc' as a multi-function driver
that will first run the preprocessor, then the compiler, then the
assembler, then the link loader....  I know that I can pass
specific flags to each.

For example:

    cc -DDEBUG foo.c

will define and pass "DEBUG" to the pre-processor then compile foo.c
pass the compiler output to the assembler then to the link/ loader and
editor and generate the default result (a.out)

Most of the interesting stuff can take a bit of thought.  This and
more is placed in a Makefile to get it right over and over.  Then make
can call the compiler and more with the correct flags, files etc.

Regards,
tom

-- 
	T o m  M i t c h e l l 
	spam unwanted email.
	SPAM, good eats, and a trademark of  Hormel Foods.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]