包含源文件是否合法? [英] Is it legal to include source file?

查看:83
本文介绍了包含源文件是否合法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

做这样的事情是否合法:

#include" x.c"在其他源文件中?

这是个好主意吗?

提前感谢您的回答,

Igor。

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.

推荐答案

mr ****** @ gmail。 com 说:

做这样的事情是合法的:

#include" x.c"在其他源文件中?
Is it legal to do something like this:
#include "x.c" in other source file?



是的。

Yes.


这是个好主意吗?
And is it good idea?



No.

No.


提前感谢您的回答,

伊戈尔。
Thank you in advance for your answers,
Igor.



那没关系,伊戈尔。将多个

thourtheth合并到一个程序中的第一种方法是将它们分别编译,然后将
链接在一起。对于ecthample来说,如果你是GNU编译器的那些东西,那么b b b b b b b b b b b b b b b b b b b b ,,,,,,,,,,,,,,,,,,,,,, br />
gcc -W -Wall -ansi -pedantic -c -o xo xc

gcc -W -Wall -ansi -pedantic -c -o yo yc

gcc -W -Wall -ansi -pedantic -c -o zo zc

gcc -W -Wall -ansi -pedantic -o foo xo yo zo


我可能会因为你冒犯你的实施情况而感到害羞吗?
第三方图书馆fathilitieth?


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上述域名中, - www。

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.


Richard Heathfield写道:
Richard Heathfield wrote:
mr******@gmail.com 说:

>>做这样的事情是否合法:
#include" x.c"在其他源文件中?
>>Is it legal to do something like this:
#include "x.c" in other source file?



是的。


Yes.


>>这是好主意吗?
>>And is it good idea?



No.


那没关系,伊戈尔。将多个

thourtheth合并到一个程序中的第一种方法是将它们分别编译,然后将
链接在一起。


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.



去过牙医吗? ;-)


几年前有一个项目我在其中包含了一个代码文件。

我正在为多个端口编写串行I / O驱动程序,但是使用单个

函数和指针/索引到与端口关联的数据区域

显着增加了中断处理时间。我写了一个

程序作为模板,然后为每个

端口设置了单独的包装函数,其中包括为
$ b $设置定义常量后的代码文件b端口值。对于每个驱动程序,端口是常量,因此不需要运行时间来进行索引或取消引用。 I / O端口也直接

地址。


底线是代码是在一个地方定义的,并且是

在多个地方实例化,以牺牲代码来优化速度

空间。想想看,它与

类似函数的宏用法和内联函数的情况类似,只是以不同的方式来调用它。

这是一种技术,但我只在特殊情况下使用。


-

Thad

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


On Sun,2007年6月3日19:02:18 +0000,Richard Heathfield

< rj*@see.sig.invalidwrote:
On Sun, 03 Jun 2007 19:02:18 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
mr******@gmail.com 说:

>做这样的事情是否合法:
#include" x.c"在其他源文件中?
>Is it legal to do something like this:
#include "x.c" in other source file?


是的。


Yes.


>这是好主意吗?
>And is it good idea?


没有。


No.


>提前感谢您的回答,Igor。
>Thank you in advance for your answers,
Igor.


那没关系,伊戈尔。合并多个
的常用方法


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



原帖中的内容是什么促使你成为这个讽刺?

中的任何值对于所有通过第二语言通过该组奋斗的参与者而言,您的回复将会丢失。你是否正在与另一组中的这张海报进行战斗?

删除del电子邮件

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


这篇关于包含源文件是否合法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆