Re: precompiled headers question
- From: "Abubakar" <emailallrise@xxxxxxxxx>
- Date: Tue, 4 Apr 2006 10:37:28 +0500
do it like this:
//common.h
extern int g_Global;
extern int MyFunction(void);
This was very helpful.
Thanks for all other tips as well. My #include problems are settling slowly
n slowly :-)
Regards,
Abubakar.
"Bruno van Dooren" <bruno_nos_pam_van_dooren@xxxxxxxxxxx> wrote in message
news:01CD0409-6B63-4D7F-ACF4-CAFE5A01CBAB@xxxxxxxxxxxxxxxx
oneWhat does the directory structure of your project look like? Inparticular,
where are stdafx.h and the file containing the #include in relation to
folders to
All my source files are not in the same folder. I have made extra
Publish,contain source and headers. For example, there is a folder called
addedwhich contains headers and sources of publishing functionality. When I
pchthese files to my project as new items, they had there first line as
"#include "stdafx.h"". That was the time when my project settings had
thatenabled. Than at some point I changed project settings to not using pch,
after which when I compiled the project I started getting these errors
sourcethere was no stdafx.h. But I knew that stdafx.h is at the root of the
fine,tree, so I just changed it to "#include "../stdafx.h"" and it compiled
loadwhich also got me thinking why was it (lets say blockpublishing.cpp)
compiling before when it had no stdafx.h on its path. (my lack of cpp
knowledge).
That is because the compiler will look for the PCH instead of trying to
the real include file.include
if you separate include and source files you have to add additional
directories in your project settings. otherwise you have to explicitlytell
the compiler where those files are (by using ../..) and that removeshave
flexibility from your project layout.
I have other problems as well, related to header files includes. Like I
variablesa common.h file that has some utility functions and some global
onethat I intend to use at more than one place. Now I include common.h at
somefile, lets say one.h and use its functions which works ok, and than at
if Iother place,lets say two.h, I include the common.h and compiler starts
giving me errors, while linking the source, saying that
"something__proc___here" is already defined in "something.obj". However
(globaldont include common.h in two.h, the two.h has no idea of the things
do isfunctions and variables) that I write, which I assume will me visible to
two.h that are inside the common.h. Now the next thing I'm planning to
with
do it like this:
//common.h
extern int g_Global;
extern int MyFunction(void);
//common.cpp
#include "common.h"
int g_Global;
int MyFunction(void)
{
//...
}
that way there is only 1 definition, and you can use them by simply
including common.h
inlcude my common.h in stdafx.h and see what happens. Also will play
and#pragma once stuff which looks insteresting and I hope its not microsoft
specific.
another thing you'll see often is this:
#ifndef __SOME_INCLUDE_GUARD__
#define__SOME_INCLUDE_GUARD__
//declarations here
#endif
The purpose I wrote this second para above is:
Having a C# background, I think I really need to read some really good
c++detailed article on the problems that a dev can face while working on
elseprojects having to do with #include. It would be great if you or anyone
specific.has some web links on this, or maybe discuss here.
to find out if something is MSFT specific, find the topic in the MSDN help
collection. it is always mentioned if something is ANSI or microsoft
several.
www.codeproject.com is always a good place to start when looking for info.
if you are serious about C++ you should buy a good book. there are
my favorite is still 'the C++ programming language' by stroustrub
it can be a bit dull at times, but it is complete.
if you have specific questions you can always ask them here also.
--
Kind regards,
Bruno.
bruno_nos_pam_van_dooren@xxxxxxxxxxx
Remove only "_nos_pam"
.
- References:
- Re: precompiled headers question
- From: Abubakar
- Re: precompiled headers question
- From: Bruno van Dooren
- Re: precompiled headers question
- Prev by Date: Re: precompiled headers question
- Next by Date: Re: C/C++ Console App running 10 times slower in VS2005 from VS2003
- Previous by thread: Re: precompiled headers question
- Next by thread: Re: Linker error 1104
- Index(es):