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? 20 1635
"Bonj" <benjtaylor at hotpop d0t com> wrote in message
news:u7******** ******@TK2MSFTN GP10.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******** ******@TK2MSFTN GP12.phx.gbl... "Bonj" <benjtaylor at hotpop d0t com> wrote in message news:u7******** ******@TK2MSFTN GP10.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******** *******@TK2MSFT NGP09.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************* **********@hotm ail.com
Above views may belong only to me.
"Bonj" <benjtaylor at hotpop d0t com> wrote in message
news:%2******** *******@TK2MSFT NGP09.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.
Oh, you can set one *.c file to create another *.pch for all your other *.c
files to use.
--
Jeff Partch [VC++ MVP]
> 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.
Mmmm... it usually gets its knickers in a twist whenever I try to modify the
build settings, normally. 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.
I think it would be better if you could set different build settings for
different files, this would allow you to compile managed and unmanaged ones
separately (separate issue, but...), then you could be sure they were
compiling the way you want. 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.
Nah, I wouldn't dream of doing that. I love my C files, I want to keep them
that way - and I won't be forcing them to compile as C++. I'd do it in
assembly language if I knew it, but I don't! I generally think C to be good
for memory and such functions as manipulating resources, whereas all the
high-level ATL stuff is taken care of by the C++ side. The C files are the
only ones that are going to be modifying the global memory of the
application (well, DLL) - all of the stuff in the C++ ones is localized in
the ATL -based classes. It doesn't use any heap either - all of the memory
is in a resource file loaded into global namespace.
Cheers
"Bonj" <benjtaylor at hotpop d0t com> wrote in message
news:%2******** *******@TK2MSFT NGP09.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.
Could you hack up the stdafx.h into two sections separated by
#ifdef _cplusplus
...
#else
...
#endif
Norm
"Bonj" <benjtaylor at hotpop d0t com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
[Brasfield once wrote:] 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. Nah, I wouldn't dream of doing that. I love my C files, I want to keep them that way - and I won't be forcing them to compile as C++. I'd do it in assembly language if I knew it, but I don't! I generally think C to be good for memory and such functions as manipulating resources, whereas all the high-level ATL stuff is taken care of by the C++ side. The C files are the only ones that are going to be modifying the global memory of the application (well, DLL) - all of the stuff in the C++ ones is localized in the ATL -based classes. It doesn't use any heap either - all of the memory is in a resource file loaded into global namespace.
You seem to suffer under the misapprehension that
you would have to change the nature of your C code
in order to compile it as C++. That is not what I was
suggesting. If your C files are already ANSI C (rather
than the ancient K&R C), then with just a little work,
and no changes to the way the code operates, they
can be made acceptable to the C++ compiler. This
means a little less sloppiness with respect to typing,
and a few casts to make explicit what was implicit
in the C version, but the sequence of assignments
and calls, the data structures, and the form of
expressions can remain as they were. You need
not add any classes, use namespaces, or emply
any other purely C++ features. This usage is
commonly known as "using C++ as a better C".
(Of course, some C diehards quibble with this!)
Cheers
OK.
--
--Larry Brasfield
email: do************* **********@hotm ail.com
Above views may belong only to me.
"Norm Dresner" <nd***@att.ne t> wrote in message
news:nD******** ******@bgtnsc05-news.ops.worldn et.att.net... "Bonj" <benjtaylor at hotpop d0t com> wrote in message news:%2******** *******@TK2MSFT NGP09.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.
Could you hack up the stdafx.h into two sections separated by #ifdef _cplusplus ... #else ... #endif
Norm
I just looked at the M/S on-line documentation for precompiled headers and
found this statement
"Although you can use only one precompiled header (.pch) file per source
file, you can use multiple .pch files in a project"
Would this accomplish some of what you want?
Norm You seem to suffer under the misapprehension that you would have to change the nature of your C code in order to compile it as C++.
No, I don't - I suffer the apprehension (mis~ or otherwise) that there would
be no advantage in performance in converting it to C. The way I see it, it
is the same compiler backend that is building my program, but in C, it is
doing simpler things when compiling and having to conform to a stricter set
of rules about what it can do than when doing C++.
I personally very much doubt that there is any way of using the C++-only
features or the way C++ compiles that C doesn't, in order to increase the
speed of the program. But if this is what you meant by "using C++ as a
better C", then please tell me what they are - because I don't know them!
What I mean is, when I compile C, it is an old language that has been around
since the seventies or something. But the compiler I'm using hasn't been
around since the seventies, so the only advantages in using C++ would be in
what functionality I could use, not performance.
My C files would be acceptable to the C++ compiler, apart from the 'extern
"C" ...' bit. But without the precompiled headers, they're acceptable to the
C compiler aswell. It's like in a web application, if you're not using the
session state, you might aswell turn it off.
That is not what I was suggesting. If your C files are already ANSI C (rather than the ancient K&R C),
Oh god yes, they're standard, modern C. They compile with the MS 7.1
compiler just like the C++ files do, it's just they've got a .c extension.
No ancient compilers that use weird specifics or anything.
then with just a little work, and no changes to the way the code operates, they can be made acceptable to the C++ compiler. This means a little less sloppiness with respect to typing, and a few casts to make explicit what was implicit in the C version,
I never do implicit casts anyway. I always use, for instance:
HMODULE hMod = (HMODULE)hInsta nce
I'm presuming this is faster than the static_cast<typ e> thingy or other?
but the sequence of assignments and calls, the data structures, and the form of expressions can remain as they were. You need not add any classes, use namespaces, or emply any other purely C++ features. This usage is commonly known as "using C++ as a better C". (Of course, some C diehards quibble with this!)
Cheers
OK.
-- --Larry Brasfield email: do************* **********@hotm ail.com Above views may belong only to me. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Asfand Yar Qazi |
last post by:
Hi,
Now that GCC 3.4 has precompiled headers, I'm thinking I can stop
using pimpls to speed up development time, as it may make life
easier (declaring pimpls takes a long time...)
What are the views of the experienced users of various C++
implementations? Do precompiled headers allow pimpls to be
avoided while maintaining the same speed up of development time?
|
by: unspammable |
last post by:
Several C++ compilers now allow precompiled headers, supposedly as a
compile-time optimization.
I personally do not use them, although I code mostly in VC++ (which has
a tendency to shove PCH down your throat), because:
a. When headers are lumped together into one huge entity the code loses
a sense of who-uses-what, or so it seems to me. I like to be able to
know from the include directives of each file as much as I can about
the...
|
by: JoeS |
last post by:
Is there anyway to share a single pch file between
projects in VC 7.0? I have 300+ projects each of which
creates its own pch. All projects include the exact same
header files in the precompiled header. Its takes about 7
seconds to create the precompiled header for each project.
That's 35 minutes spent creating precompiled headers for
all project! All of the projects use PDB files for debug
info.
I tried creating Precomp.pch in project...
|
by: dt |
last post by:
Having troubles with my program and i believe it has something to do with my
project settings for precompiled headers. This is what i have: my main cpp
file, vector.h/cpp and polygon.h/cpp.
vector.h includes math, polygon includes vector and gl/gl.h, and main
includes windows.h, gl/gl.h, gl/glu.h, gl/glaux.h and polygon.h
i've tried setting all of them to 'using precompiled headers' and i get:
fatal error C1010: unexpected end of file...
|
by: citizenkahn |
last post by:
I read an article entitled "Sharing precompiled headers between
projects" on this group. I am in the same situation as the requesting
author, but the solution has not worked for me.
Here is my situation, if anyone has a clue as to how I can solve this,
please let me know.
I am using VS.NET 2003 Arch. I have a solution two projects, a library
and an exe. The exe depends upon the library. Both build with /zi in
| |
by: Alvo von Cossel I |
last post by:
yo,
i have a simple hello world win32 console application. it should work but
there is an error. here is the most important part of the error:
have you forgotten to add #include <stdfx.h> to your source code?
stdfx.h is a precompiled header and i have deleted it but vc++ still asks me
to include it. how do i change the precompiled header setting?
--
|
by: Kevin Frey |
last post by:
I am working on a test migration of our project to Visual Studio 2005 Beta 2
as a precursor to the availability of the full release of VS2005.
The most onerous problem so far concerns the requirement by LINK.EXE that if
an object file has used precompiled headers, then the resulting "precompiled
header object file" must also be one of the objects in the link.
(Whilst it does not affect my problem - I would dearly like to know why this...
|
by: simon.hudon |
last post by:
Hi everyone,
I have a strange problem with precompiled headers with VC8. I have the
problem while trying to use a precompiled header to build another
precompiled header. I tried the sample code provided on msdn for the
use of /Yu /Yc and while it works well with VC++ 7.0, it doesn't with
VC++ 8.0 (http://msdn2.microsoft.com/en-us/library/2yzw0wyd.aspx).
It gives me this error under VC 8:
level2.cpp(3) : fatal error C1083: Cannot...
|
by: Abubakar |
last post by:
Hi,
I am writing some unmanaged c++ code that would need to be compiled in the
future using compilers other than vc++. I'm using the feature of vc++ "use
precompiled headers", is there going to be any problem if I compile this
code on other compilers? I'm asking this because when I use pch *some* of my
cpp files has following as there first line
#include "StdAfx.h"
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |