Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Is it legal to include source file?

Reply
Thread Tools

Is it legal to include source file?

 
 
mr.polik@gmail.com
Guest
Posts: n/a
 
      06-03-2007
Is it legal to do something like this:
#include "x.c" in other source file?
And is it good idea?
Thank you in advance for your answers,
Igor.

 
Reply With Quote
 
 
 
 
Richard Heathfield
Guest
Posts: n/a
 
      06-03-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) said:

> Is it legal to do something like this:
> #include "x.c" in other source file?


Yes.

> And is it good idea?


No.

> Thank you in advance for your answers,
> Igor.


That'th all right, Igor. The uthual way to incorporate multiple
thourtheth into one program ith to compile them theparately, and then
link them together. For ecthample, if you are uthing the GNU compiler
(which begth to be lithped, but I lack thuffithient thpittle), you
might do thith:

gcc -W -Wall -ansi -pedantic -c -o x.o x.c
gcc -W -Wall -ansi -pedantic -c -o y.o y.c
gcc -W -Wall -ansi -pedantic -c -o z.o z.c
gcc -W -Wall -ansi -pedantic -o foo x.o y.o z.o

Might I altho thuggetht that you invethtigate your implementathion'th
third-party library fathilitieth?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
 
Reply With Quote
 
 
 
 
Barry Schwarz
Guest
Posts: n/a
 
      06-03-2007
On Sun, 03 Jun 2007 19:02:18 +0000, Richard Heathfield
<(E-Mail Removed)> wrote:

> (E-Mail Removed) said:
>
>> Is it legal to do something like this:
>> #include "x.c" in other source file?

>
>Yes.
>
>> And is it good idea?

>
>No.
>
>> Thank you in advance for your answers,
>> Igor.

>
>That'th all right, Igor. The uthual way to incorporate multiple


What in the original post prompted you to be this snide? Any value in
your response will be lost on all the participants who struggle
through this group in a second language. Are you having a running
battle with this poster in a different group?


Remove del for email
 
Reply With Quote
 
Thad Smith
Guest
Posts: n/a
 
      06-03-2007
Richard Heathfield wrote:
> (E-Mail Removed) said:
>
>>Is it legal to do something like this:
>>#include "x.c" in other source file?

>
> Yes.
>
>>And is it good idea?

>
> No.
>
> That'th all right, Igor. The uthual way to incorporate multiple
> thourtheth into one program ith to compile them theparately, and then
> link them together.


Been to the dentist?

There was a project several years ago in which I included a code file.
I was writing serial I/O drivers for multiple ports, but using a single
function and pointers/indexes to the data area associated with the port
significantly increased the interrupt processing time. I wrote one
procedure as a template, then had separate wrapper functions for each
port which included the code file after setting a defined constant for
the port value. For each driver the port was constant, so no run-time
indexing or dereferencing was needed. The I/O ports were also directly
addressed.

Bottom line was that the code was defined in one place, and was
instantiated in multiple places to optimize speed at the expense of code
space. Come to think of it, that's similar to what happens with
function-like macro usage, and inline functions, just a different way to
invoke it.

It's a technique, though, which I use only in special circumstances.

--
Thad
 
Reply With Quote
 
Tim Prince
Guest
Posts: n/a
 
      06-03-2007
Thad Smith wrote:
> Richard Heathfield wrote:
>> (E-Mail Removed) said:
>>
>>> Is it legal to do something like this:
>>> #include "x.c" in other source file?

>>
>> Yes.
>>
>>> And is it good idea?

>>
>> No.


>
> Bottom line was that the code was defined in one place, and was
> instantiated in multiple places to optimize speed at the expense of code
> space. Come to think of it, that's similar to what happens with
> function-like macro usage, and inline functions, just a different way to
> invoke it.
>
> It's a technique, though, which I use only in special circumstances.
>

I've seen it done where the same code is instantiated with multiple data
types. As it was done that way by people more expert than the average
of those whose code I inherit, I work with it, rather than pass judgment.
 
Reply With Quote
 
Ben Pfaff
Guest
Posts: n/a
 
      06-03-2007
Thad Smith <(E-Mail Removed)> writes:

> There was a project several years ago in which I included a code
> file. I was writing serial I/O drivers for multiple ports, but using a
> single function and pointers/indexes to the data area associated with
> the port significantly increased the interrupt processing time. I
> wrote one procedure as a template, then had separate wrapper functions
> for each port which included the code file after setting a defined
> constant for the port value. For each driver the port was constant,
> so no run-time indexing or dereferencing was needed. The I/O ports
> were also directly addressed.


This technique sometimes makes sense, but I'd suggest that giving
an included code file a .c extension is misleading. When I do
something like this, I use a .inc or .def or other extension that
is less likely to surprise programmers reading the code later.
--
"Welcome to the wonderful world of undefined behavior, where the demons
are nasal and the DeathStation users are nervous." --Daniel Fox
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      06-03-2007
Barry Schwarz said:

> On Sun, 03 Jun 2007 19:02:18 +0000, Richard Heathfield
> <(E-Mail Removed)> wrote:
>
>> (E-Mail Removed) said:
>>

<snip>
>>
>>> Thank you in advance for your answers,
>>> Igor.

>>
>>That'th all right, Igor. The uthual way to incorporate multiple

>
> What in the original post prompted you to be this snide?


What maketh you think I'm being thnide? Have you never read any
Dithcworld bookth?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      06-03-2007
On Sun, 03 Jun 2007 21:50:10 +0000, in comp.lang.c , Richard
Heathfield <(E-Mail Removed)> wrote:

>Barry Schwarz said:
>
>> On Sun, 03 Jun 2007 19:02:18 +0000, Richard Heathfield
>> <(E-Mail Removed)> wrote:
>>
>>> (E-Mail Removed) said:
>>>

><snip>
>>>
>>>> Thank you in advance for your answers,
>>>> Igor.
>>>
>>>That'th all right, Igor. The uthual way to incorporate multiple

>>
>> What in the original post prompted you to be this snide?

>
>What maketh you think I'm being thnide? Have you never read any
>Dithcworld bookth?


I guess the problem is that your post could be construed as an
insulting joke.

Imagine if we insisted on comparing you to Richard the Third, hump and
all, or invariably responded in Bronte-esque language and complained
about how you'd treated Cathy?

Igor is after all a real name as well as a running joke in Discworld.

(and yes, I know you won't read this, you killfiled me because you
thought I kept insulting you. Hmm, curiouser and curiouser..)
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
Reply With Quote
 
Don Bruder
Guest
Posts: n/a
 
      06-03-2007
In article <(E-Mail Removed)>,
Barry Schwarz <(E-Mail Removed)> wrote:

> On Sun, 03 Jun 2007 19:02:18 +0000, Richard Heathfield
> <(E-Mail Removed)> wrote:
>
> > (E-Mail Removed) said:
> >
> >> Is it legal to do something like this:
> >> #include "x.c" in other source file?

> >
> >Yes.
> >
> >> And is it good idea?

> >
> >No.
> >
> >> Thank you in advance for your answers,
> >> Igor.

> >
> >That'th all right, Igor. The uthual way to incorporate multiple

>
> What in the original post prompted you to be this snide?


So I'm not alone?

(I thought the same thing.)

--
Don Bruder - (E-Mail Removed) - If your "From:" address isn't on my whitelist,
or the subject of the message doesn't contain the exact text "PopperAndShadow"
somewhere, any message sent to this address will go in the garbage without my
ever knowing it arrived. Sorry... <http://www.sonic.net/~dakidd> for more info
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      06-03-2007
Don Bruder said:

> In article <(E-Mail Removed)>,
> Barry Schwarz <(E-Mail Removed)> wrote:
>
>> On Sun, 03 Jun 2007 19:02:18 +0000, Richard Heathfield
>> <(E-Mail Removed)> wrote:
>>
>> > (E-Mail Removed) said:
>> >

<snip>
>> >
>> >> Thank you in advance for your answers,
>> >> Igor.
>> >
>> >That'th all right, Igor. The uthual way to incorporate multiple

>>
>> What in the original post prompted you to be this snide?

>
> So I'm not alone?
>
> (I thought the same thing.)


Then I apologise unreservedly to the OP. Silly joke gone wrong. Sorry.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open-Source Legal Victory Lawrence D'Oliveiro NZ Computing 1 02-22-2010 03:33 AM
Is it legal to rebuild Python.exe to include Version property tab? ward.david@comcast.net Python 1 07-15-2008 05:46 PM
/* #include <someyhing.h> */ => include it or do not include it?That is the question .... Andreas Bogenberger C Programming 3 02-22-2008 10:53 AM
is there a way to "include" source file B.html in source file A.html? Cloud Burst HTML 11 01-09-2004 02:49 AM
Legal Risks of Open Source Under Scrutiny Peter NZ Computing 97 12-02-2003 10:27 PM



Advertisments