On Sat, Aug 23, 2003 at 01:34:07AM -0700, reza saeidinia wrote:
> I have a project and in my project I have some folders. in any of my
> folders there are some c and h files.

First, you're going to get some grumbles from the extreme conservatives
about terminology--it's not important, but reduces the friction.

You have subdirectories (folders) in your top-level source directory
(project).

> the files in the folders dont know headers in the base project folder
> and other folders.and all of files exist in project.
>
> how I can solve this problem?

There are conventions, and tools.

The usual convention is to create an "include" directory in the top-level
source directory.  All headers that are common to the entire "build product"
(more on that in a moment) should be placed in that directory.

Typically, it's useful to segregate the sources in a software product into
sub-products, e.g., the different object files that make up a library,
or simply logically related files that provide a subsystem.  It sounds
like your source is already organized in that manner.

It's conventional to also create an "include" directory in each of these
subdirectories, and move the header files into that directory.
(This is because you now have an hierarchical structure--if one of
these subdirectories gets too big/complex, it can be further subdivided;
common header files can be in the top-level include directory for use
by objects deeper in the tree.)

Now, as to actually BUILDING the sources--the low-level mechanism is the
include option to the compiler, "-I".  You can provide a search path via
repetitive use of this option, e.g., "-I ../include -I ./include" will
search the include directory one level up from the working directory,
then it will search the include directory in the current directory.

But you don't want to do that by hand.  Look up the "make" command.
You will want to create a "makefile" in each directory, and invoke them
in what's knowns as a "postorder traversal"--in English, starting at the
bottom and working your way up.  This allows you to make "intermediate
objects" out of products from the lower-level builds.

BTW, this all exists in Visual C++, but most of it is hidden from you.
The VC++ IDE can even generate Makefiles for use by "make"...

This sounds more complicated than it really is.  Read about "make", and
look up the "-I" compiler option, and look at some of the makefiles and
source hierarchies for some Open Source packages.

G'luck,
-- 
        Dave Ihnat
        [EMAIL PROTECTED]


-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list

Reply via email to