|
List Info
Thread: Complete, and utter automation with Jam
|
|
| Complete, and utter automation with Jam |

|
2006-08-20 00:29:00 |
Hi all,
Thanks for all your responses!
Brian said:
> But from his original post, it sounds like he's doing
something EXTREMELY
> non-standard (and bad). Just to clarify: do you
actually #include all
> yoursource code (.c files) in a single file!?
Sorry, when I typed the three source files, I accidentally
put #include
in front of them. Instead, the only #include listed in
"main.c" is
"data.h".
> solutions, but they're all really fragile, and will
only work in very
> constrained situations. Do you have source files in
multiple directories,
> for example?
Well not at the moment, but of course I may in the future. I
think I can
see
where you're coming from, but as long as .h and .c files
are kept together,
there shouldn't be a problem. After all, if we can keep
things like
stdlib.h
and print.h in the source file, and that can compile without
the need of
a makefile, then the same should apply one's own .h files ?
John said:
> How should it "know" to link to data.c ?
> Is this purely by naming convention?
Well the same issue is involved with stdlib.h and print.h,
but they manage
to get round it for some reason.
> There are plenty of cases where XXX.h may be included
and that may mean
> that
> AAA.c, BBB.c, and DDD.c are the ones it should
"know" to include, but
> that
> does not have the advantage of a naming convention.
So there is a use to naming the .c files different from the
.h files? Is
that
something to do with two or more different .c files having
the same set of
function names or variables as one 'master' .h file? Do
you think it would
be
a good idea to have a naming convention where at least one c
file must be
named the same as each .h file?
This is going a bit off topic, and I could well be mistaken
and maybe
header
files have some intrinsic use. But I'm wondering if maybe
they are used
these
days only because otherwise the whole c structure / compiler
situation
would need a rewrite otherwise. Ideally, I think that the
programmer
should be
able include c files directly into other c files (no .h
files at all). As
long,
as the compiler (or make) is super intelligent, and doesn't
recompile files
unnecessarily, things should go fine. I could be hopelessly
misguided on
this,
but I'm sure it's possible in principle, without
compromising any of the
power
of c/c++.
It's the same principle as having to declare the functions
(a waste of
time).
Okay it's useful info for the programmer, but ultimately
this should be
left
to the IDE enviroment to display for automation.
Cheers, Daniel
http://www.skytopia.com
_______________________________________________
jamming mailing list - jamming perforce.com
http://maillist.perforce.com/mailman/listinfo/jamming
|
|
| Complete, and utter automation with Jam |

|
2006-08-20 06:00:39 |
> > How should it "know" to link to data.c
?
> > Is this purely by naming convention?
>
> Well the same issue is involved with stdlib.h and
print.h, but they manage
> to get round it for some reason.
When you #include stdlib.h, you are not getting any source
code, just
definitions of functions / etc.
The actual code is compiled in a static library, which is
typically
linked in by default so you don't have to specify it
manually.
What I mean is that there is no "stdlib.c" file
that gets
automatically put along with your sources.
In fact, the functions in stdlib.h are defined in a variety
of
different .c files - the rand() function is in rand.c,
strtod() is in
strtod.c, and so on.
They are all compiled into a library so they can be included
as a
single unit by your program.
Thus in response to your question:
> So there is a use to naming the .c files different from
the .h files?
Yes, there is - at least that is how it is done in this copy
of the c
standard library source I have hanging around.
Have you been programming C/C++ for long ?
I have, for instance, seen similar conceptual issues come up
with some
Java programmers when switching to C/C++, as Java has no
notion of
headers/sources.
-John
On 8/19/06, Daniel White <twinbee41 skytopia.com> wrote:
> Hi all,
>
> Thanks for all your responses!
>
> Brian said:
>
> > But from his original post, it sounds like he's
doing something EXTREMELY
> > non-standard (and bad). Just to clarify: do you
actually #include all
> > yoursource code (.c files) in a single file!?
>
> Sorry, when I typed the three source files, I
accidentally put #include
> in front of them. Instead, the only #include listed in
"main.c" is
> "data.h".
>
> > solutions, but they're all really fragile, and
will only work in very
> > constrained situations. Do you have source files
in multiple directories,
> > for example?
>
> Well not at the moment, but of course I may in the
future. I think I can
> see
> where you're coming from, but as long as .h and .c
files are kept together,
> there shouldn't be a problem. After all, if we can
keep things like
> stdlib.h
> and print.h in the source file, and that can compile
without the need of
> a makefile, then the same should apply one's own .h
files ?
>
>
> John said:
>
> > How should it "know" to link to data.c
?
> > Is this purely by naming convention?
>
> Well the same issue is involved with stdlib.h and
print.h, but they manage
> to get round it for some reason.
>
>
> > There are plenty of cases where XXX.h may be
included and that may mean
> > that
> > AAA.c, BBB.c, and DDD.c are the ones it should
"know" to include, but
> > that
> > does not have the advantage of a naming
convention.
>
> So there is a use to naming the .c files different from
the .h files? Is
> that
> something to do with two or more different .c files
having the same set of
> function names or variables as one 'master' .h file?
Do you think it would
> be
> a good idea to have a naming convention where at least
one c file must be
> named the same as each .h file?
>
> This is going a bit off topic, and I could well be
mistaken and maybe
> header
> files have some intrinsic use. But I'm wondering if
maybe they are used
> these
> days only because otherwise the whole c structure /
compiler situation
> would need a rewrite otherwise. Ideally, I think that
the programmer
> should be
> able include c files directly into other c files (no .h
files at all). As
> long,
> as the compiler (or make) is super intelligent, and
doesn't recompile files
> unnecessarily, things should go fine. I could be
hopelessly misguided on
> this,
> but I'm sure it's possible in principle, without
compromising any of the
> power
> of c/c++.
>
> It's the same principle as having to declare the
functions (a waste of
> time).
> Okay it's useful info for the programmer, but
ultimately this should be
> left
> to the IDE enviroment to display for automation.
>
> Cheers, Daniel
> http://www.skytopia.com
> _______________________________________________
> jamming mailing list - jamming perforce.com
> http://maillist.perforce.com/mailman/listinfo/jamming
>
_______________________________________________
jamming mailing list - jamming perforce.com
http://maillist.perforce.com/mailman/listinfo/jamming
|
|
| Complete, and utter automation with Jam |

|
2006-09-06 12:56:37 |
Hi John,
>> > How should it "know" to link to
data.c ?
>> > Is this purely by naming convention?
>>
>> Well the same issue is involved with stdlib.h and
print.h, but they
>> manage
>> to get round it for some reason.
>
> When you #include stdlib.h, you are not getting any
source code, just
> definitions of functions / etc.
> The actual code is compiled in a static library, which
is typically
> linked in by default so you don't have to specify it
manually.
Right okay, that makes sense.
> What I mean is that there is no "stdlib.c"
file that gets
> automatically put along with your sources.
> In fact, the functions in stdlib.h are defined in a
variety of
> different .c files - the rand() function is in rand.c,
strtod() is in
> strtod.c, and so on.
> They are all compiled into a library so they can be
included as a
> single unit by your program.
Woudln't it be more space efficient for C to only include
the necessary
functions required for the operation of a particular
program? Mind
you, I suppose the cost would having to recompile the source
each
time...
> Thus in response to your question:
>> So there is a use to naming the .c files different
from the .h files?
>
> Yes, there is - at least that is how it is done in this
copy of the c
> standard library source I have hanging around.
>
> Have you been programming C/C++ for long ?
> I have, for instance, seen similar conceptual issues
come up with some
> Java programmers when switching to C/C++, as Java has
no notion of
> headers/sources.
Rumbled! Okay,
it's true, I came from a Java background, and
switched to C because of the speed. However, the language D,
which
is an upgrade from C, doesn't bother with them. Hmm... I
wonder why ;)
Dan
>
> -John
>
> On 8/19/06, Daniel White <twinbee41 skytopia.com> wrote:
>> Hi all,
>>
>> Thanks for all your responses!
>>
>> Brian said:
>>
>> > But from his original post, it sounds like
he's doing something
>> EXTREMELY
>> > non-standard (and bad). Just to clarify: do
you actually #include all
>> > yoursource code (.c files) in a single file!?
>>
>> Sorry, when I typed the three source files, I
accidentally put #include
>> in front of them. Instead, the only #include listed
in "main.c" is
>> "data.h".
>>
>> > solutions, but they're all really fragile,
and will only work in very
>> > constrained situations. Do you have source
files in multiple
>> directories,
>> > for example?
>>
>> Well not at the moment, but of course I may in the
future. I think I can
>> see
>> where you're coming from, but as long as .h and .c
files are kept
>> together,
>> there shouldn't be a problem. After all, if we can
keep things like
>> stdlib.h
>> and print.h in the source file, and that can
compile without the need of
>> a makefile, then the same should apply one's own
.h files ?
>>
>>
>> John said:
>>
>> > How should it "know" to link to
data.c ?
>> > Is this purely by naming convention?
>>
>> Well the same issue is involved with stdlib.h and
print.h, but they
>> manage
>> to get round it for some reason.
>>
>>
>> > There are plenty of cases where XXX.h may be
included and that may
>> mean
>> > that
>> > AAA.c, BBB.c, and DDD.c are the ones it should
"know" to include, but
>> > that
>> > does not have the advantage of a naming
convention.
>>
>> So there is a use to naming the .c files different
from the .h files? Is
>> that
>> something to do with two or more different .c files
having the same set
>> of
>> function names or variables as one 'master' .h
file? Do you think it
>> would
>> be
>> a good idea to have a naming convention where at
least one c file must
>> be
>> named the same as each .h file?
>>
>> This is going a bit off topic, and I could well be
mistaken and maybe
>> header
>> files have some intrinsic use. But I'm wondering
if maybe they are used
>> these
>> days only because otherwise the whole c structure /
compiler situation
>> would need a rewrite otherwise. Ideally, I think
that the programmer
>> should be
>> able include c files directly into other c files
(no .h files at all).
>> As
>> long,
>> as the compiler (or make) is super intelligent, and
doesn't recompile
>> files
>> unnecessarily, things should go fine. I could be
hopelessly misguided on
>> this,
>> but I'm sure it's possible in principle, without
compromising any of the
>> power
>> of c/c++.
>>
>> It's the same principle as having to declare the
functions (a waste of
>> time).
>> Okay it's useful info for the programmer, but
ultimately this should be
>> left
>> to the IDE enviroment to display for automation.
>>
>> Cheers, Daniel
>> http://www.skytopia.com
>> _______________________________________________
>> jamming mailing list - jamming perforce.com
>> http://maillist.perforce.com/mailman/listinfo/jamming
>>
--
www.skytopia.com
_______________________________________________
jamming mailing list - jamming perforce.com
http://maillist.perforce.com/mailman/listinfo/jamming
|
|
| Complete, and utter automation with Jam |

|
2006-09-13 23:01:41 |
|
On 9/6/06, Daniel White <skytopia.com">twinbee41 skytopia.com> wrote:
> What I mean is that there is no "stdlib.c" file that gets > automatically put along with your sources. > In fact, the functions in stdlib.h are defined in a variety of > different .c files - the rand() function is in
rand.c, strtod() is in > strtod.c, and so on. > They are all compiled into a library so they can be included as a > single unit by your program.
Woudln't it be more space efficient for C to only include the necessary
functions required for the operation of a particular program? Mind you, I suppose the cost would having to recompile the source each time... Some linkers will attempt to eliminate redundant functions that aren't referenced.
What you're saying may be true of small projects but for larger ones recompiling the source is not desirable due to the size (and yes, time). We break large projects into smaller translation units for many reasons, not for C, but for practical reasons such as, easier for us humans to digest, encapsulation, less recompiling time when a few functions change, distribution across many computers, etc. Further to this is the organisation of libraries of code, sometimes to enforce a hierarchy of dependencies so that low level code doesn't access high level code. Without these designs a large program can become a real big mess to maintain and understand. This means there is a need for a convention of declaring what is in these units so that each c file may "include" the declarations referenced by it and that later the linker will use to resolve.
Back to your original question to me.. If you have several programs in the same directory then in Jam you would just list them:
Main progA : progA.cpp ; Main progB : progB.cpp ;
Main progC : progC.cpp ;
If you use a naming convention you can Glob for the main program sources:
PROGRAMS = [ Glob $(SUBDIR) : prog*.cpp ] ;
Make a rule in your jamrules to compile a batch:
rule BulkMain { local i ; for i in $(<) { Main $(i:B) : $(i:BS) ; } }
And in your jamfiles:
BulkMain $(PROGRAMS) ;
If you use this method, just be aware that if you need different options,
e.g. LINKFLAGS for each program you'll need to invent some more utility rules to help tell jam what to do.
Craig.
|
[1-4]
|
|