C上的预编译头文件 [英] Precompiled headers on C

查看:90
本文介绍了C上的预编译头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以避免在文件上使用预编译的标题,而不是
#include" stdafx.h"。

我有一个ATL项目,在stdafx.h中有很多ATL #includes。

我现在需要在这个项目中添加一些.c文件,编译为生硬的

C - 不是C ++。

.c文件显然不会理解< atlbase.h>

stdafx.h中的等等。

但是如果我将预编译的头文件打开,它会抱怨致命的

文件末尾被发现寻找预编译头指令,显然在

.c文件中。我虽然预编译的标题只是这样,当它*包含* b / b
时,它知道如果.obj文件比.h文件更新,它就是

didn不必重新编译它......是不是这样?

我打算将.c文件放在一个静态库项目中,但它会转动

因为.c文件的目的是

访问资源数据,所以它更麻烦。

任何想法?

解决方案

" Bonj" < benjtaylor at hotpop d0t com>在留言中写道

news:u7 ************** @ TK2MSFTNGP10.phx.gbl ...

是否可以避免在没有#include" stdafx.h"的文件上使用预编译头文件。
我有一个ATL项目,它的
stdafx中有很多ATL #includes。 H。我现在需要在这个项目中添加一些.c文件,编译为硬盘原始的C - 而不是C ++。
.c文件显然不会理解< atlbase.h>在
stdafx.h中的等等。




在解决方案资源管理器中右键单击该文件,然后单击属性。你可能会想要选择''所有配置'',然后选择:'C / C ++>预编译

标题>创建/使用预编译标题=不使用预编译标题。

-

Jeff Partch [VC ++ MVP]


是的,我知道,那是''正是我所做的。但它并没有完全取得使用stdafx.h的好处。

我想知道是否有某些方法你仍然可以利用

使用.c文件时预编译的标题。

" Jeff Partch [MVP]" < JE *** @ mvps.org>在消息中写道

news:uG ************** @ TK2MSFTNGP12.phx.gbl ...

" Bonj" < benjtaylor at hotpop d0t com>在消息中写道
新闻:u7 ************** @ TK2MSFTNGP10.phx.gbl ...

是否可以避免使用预编译的头文件那些没有#include" stdafx.h的文件。
我有一个ATL项目,它的


stdafx中有很多ATL #includes。 h。

我现在需要在这个项目中添加一些.c文件,这些文件编译为硬盘原始的C - 而不是C ++。
.c文件显然不会了解< atlbase.h>在


stdafx.h。



在解决方案资源管理器中右键单击该文件,然后单击属性。您可能希望选择所有配置,然后选择:
C / C ++>预编译
标题>创建/使用预编译标题=不使用预编译标题。
-
Jeff Partch [VC ++ MVP]



" Bonj" < benjtaylor at hotpop d0t com>在留言新闻中写道:%2 *************** @ TK2MSFTNGP09.phx.gbl ...

是的我知道,那就是我的意思完成了。但它并没有完全利用stdafx.h的好处。
我想知道在使用.c文件时是否还有某些方法可以使用预编译头的优势。




有。您可以设置一个构建,其中预编译几个不同的
分组标题,然后根据需要对不同的源使用任何一个

预编译。要了解它是如何工作的,请研究关于编译器选项的文档

与预编译有关。


我可能错了但是,用IDE的半无脑自动构建系统来实现这一目标可能是难以理解的过程。然后,您将面临创建

的替代构建过程。许多这样的存在和很多

由于各种原因发现它们很有吸引力,通常是因为它们允许这样的灵活性,因此它们具有这种灵活性。


对于你情况,我希望你会更好。

让你的.c文件编译为C ++。通常,

所做的更改都是改进。


-

- 拉里布拉斯菲尔德

电子邮件:做****** *****************@hotmail.com

以上观点可能仅属于我。


Is it possible to avoid using precompiled headers on files that don''t
#include "stdafx.h".
I have an ATL project,which has got a lot of ATL #includes in its stdafx.h.
I now need to add some .c files to this project, that compile as hard raw
C - not C++.
The .c files obviously won''t understand the <atlbase.h> etc that are in the
stdafx.h.
But if I leave the precompiled headers switch on, it complains that fatal
end of file was found looking for precompiled header directive, obviously in
the .c files. I though precompiled headers were just so that when it *did*
get included, it knew that if the .obj file was newer than the .h file, it
didn''t have to recompile it.... is this not so?
I was going to put the .c files in a static library project, but it turns
out that it''s more messy that way as the purpose of the .c files is to
access resource data.
Any ideas?

解决方案

"Bonj" <benjtaylor at hotpop d0t com> wrote in message
news:u7**************@TK2MSFTNGP10.phx.gbl...

Is it possible to avoid using precompiled headers on files that don''t
#include "stdafx.h".
I have an ATL project,which has got a lot of ATL #includes in its stdafx.h. I now need to add some .c files to this project, that compile as hard raw
C - not C++.
The .c files obviously won''t understand the <atlbase.h> etc that are in the stdafx.h.



Right-click on the file in the Solution Explorer, then Properties. You''ll
probably want to select ''All Configurations'' followed by: C/C++>Precompiled
Headers>Create/Use Precompiled Header = Not Using Precompiled Headers.
--
Jeff Partch [VC++ MVP]


Yes I know, that''s exactly what I have done. But it doesn''t exactly take the
benefit of using the stdafx.h.
I was wondering if there was some way you could still use the advantage of
precompiled headers while using .c files.
"Jeff Partch [MVP]" <je***@mvps.org> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...

"Bonj" <benjtaylor at hotpop d0t com> wrote in message
news:u7**************@TK2MSFTNGP10.phx.gbl...

Is it possible to avoid using precompiled headers on files that don''t
#include "stdafx.h".
I have an ATL project,which has got a lot of ATL #includes in its


stdafx.h.

I now need to add some .c files to this project, that compile as hard raw
C - not C++.
The .c files obviously won''t understand the <atlbase.h> etc that are in


the

stdafx.h.



Right-click on the file in the Solution Explorer, then Properties. You''ll
probably want to select ''All Configurations'' followed by:
C/C++>Precompiled
Headers>Create/Use Precompiled Header = Not Using Precompiled Headers.
--
Jeff Partch [VC++ MVP]



"Bonj" <benjtaylor at hotpop d0t com> wrote in message news:%2***************@TK2MSFTNGP09.phx.gbl...

Yes I know, that''s exactly what I have done. But it doesn''t exactly take the benefit of using the stdafx.h.
I was wondering if there was some way you could still use the advantage of precompiled headers while using .c files.



There is. You can setup a build where several different
groupings of headers are precompiled, then use any one
precompilation for different sources as you see fit. To
see how that works, study the docs on compiler options
relating to precompilation.

I may be wrong about this, but getting it to happen with
the IDE''s semi-brainless automatic build system could be
a difficult process. You would then be facing creation of
an alternative build process. Many such exist and many
have found them atractive for various reasons, generally
because they allow such flexibility.

For your situation, I expect you would be better off
getting your .c files to compile as C++. Usually, the
changes necessary to do that are all improvements.

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.


这篇关于C上的预编译头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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