473,545 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is it legal to include source file?

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.

Jun 3 '07 #1
34 4056
mr******@gmail. com 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.
Jun 3 '07 #2
Richard Heathfield wrote:
mr******@gmail. com 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
Jun 3 '07 #3
On Sun, 03 Jun 2007 19:02:18 +0000, Richard Heathfield
<rj*@see.sig.in validwrote:
mr******@gmail. com 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
Jun 3 '07 #4
Thad Smith wrote:
Richard Heathfield wrote:
> mr******@gmail. com 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.
Jun 3 '07 #5
Barry Schwarz said:
On Sun, 03 Jun 2007 19:02:18 +0000, Richard Heathfield
<rj*@see.sig.in validwrote:
>mr******@gmail. com 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.
Jun 3 '07 #6
Thad Smith <Th*******@acm. orgwrites:
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
Jun 3 '07 #7
On Sun, 03 Jun 2007 21:50:10 +0000, in comp.lang.c , Richard
Heathfield <rj*@see.sig.in validwrote:
>Barry Schwarz said:
>On Sun, 03 Jun 2007 19:02:18 +0000, Richard Heathfield
<rj*@see.sig.i nvalidwrote:
>>mr******@gmail. com 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
Jun 3 '07 #8
Ben Pfaff wrote:
Thad Smith <Th*******@acm. orgwrites:
>>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.
God point, Ben. I think I used an extension of .ci.

--
Thad
Jun 3 '07 #9
Don Bruder said:
In article <a3************ *************** *****@4ax.com>,
Barry Schwarz <sc******@doezl .netwrote:
>On Sun, 03 Jun 2007 19:02:18 +0000, Richard Heathfield
<rj*@see.sig.i nvalidwrote:
mr******@gmail. com 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.
Jun 3 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4265
by: pakkocool | last post by:
¿Como ganar dinero en internet? Lee atentamente el siguiente texto, es super interesante y te hara ganar muchos dolares si sigues las instrucciones y le pones empeño: Hace unos días que estoy buscando la forma de ganar algún dinero más extra, a parte del que gano por navegar en Internet. Para ello recorro grupos de noticias, tablones,...
60
8220
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers - include application headers - include the header associated with this source file For example, in a file hello.c: #include <stdio.h>
9
13093
by: bill | last post by:
Forget the exact definition of difference between, #include <foo.h> and #include "bar.h" Normally foo.h is a standard header file, so it's path is not defined in compiler option, but I am curious how compiler find it.
12
1963
by: Francois Grieu | last post by:
Can #include safely use a preprocessing token, as in #define HEADERFILE "stdio.h" #include HEADERFILE int main(void) {return printf("Hello, world\n")*0;} TIA, François Grieu
8
2766
by: Chris Barts | last post by:
Let's say we have a library with an opaque data type implemented as a struct in the library's C source file. The definition of the struct isn't duplicated in the header included by the programs that make use of this library. Is it legal for the header and the programs that include it to declare pointers to this struct for which no definition...
5
2497
by: David Mathog | last post by:
One thing that can make porting C code from one platform to another miserable is #include. In particular, the need to either place the path to an included file within the #include statement or to very carefully define the order in which paths are searched with command line options on the compiler. Both can cause problems, especially when...
3
1686
by: Roy Hills | last post by:
I'm writing a local patch, which will be applied to several different source files. To prevent my local variables from clashing with those in the main source file, I want to create a new scope. Currently, I'm using the following, which works perfectly and I've seen used elsewhere: do { int i; int j;
19
2403
by: Sensei | last post by:
Hi! I'm concerned about the legality of such a definition: #define funcX funcY where funcX belongs to the *standard* C functions. Is it legal to do this? The standard says "any function declared in a header may be additionally implemented as a macro defined in the header, so a library function should not be declared explicitly if its...
4
4389
by: Robbie Hatley | last post by:
Some months ago, I'd asked this group: "Backtick, at-sign, dollar-sign: legal in source?" I got 20 replies, most of which were off-topic and did not answer the question. Keith Thompson provided the only direct, on-topic reply. He wrote:
0
7473
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7433
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5340
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4949
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3458
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1891
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
712
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.