how to properly create and use project files
-
Hi, I'm a bit new to visual c++ and i'm trying to figure out the right style to create and use new .h and .cpp files in vc++. Say I want to implement a new module of the project in a seperate file. And say I created the new.h and new.cpp files. Now the question is, how should I set the #include lines in the entire project in order to make it work? In new.cpp, I want to use the libraries included in stdafx.h. And in the other parts of the application that stadfx.h is included, I want to use the code that resides in new.cpp. I tried many different ways of including one another but I couldn't find an appropriate one. It either tels me that in my new.cpp file, "unexpected end of file while looking for precompiled header directive" error is present, or it reports multiple definitions. :confused: I think you got what I'm trying to do, so pls help me how to set the include graph thorughout my application. Thanx in advance.
-
Hi, I'm a bit new to visual c++ and i'm trying to figure out the right style to create and use new .h and .cpp files in vc++. Say I want to implement a new module of the project in a seperate file. And say I created the new.h and new.cpp files. Now the question is, how should I set the #include lines in the entire project in order to make it work? In new.cpp, I want to use the libraries included in stdafx.h. And in the other parts of the application that stadfx.h is included, I want to use the code that resides in new.cpp. I tried many different ways of including one another but I couldn't find an appropriate one. It either tels me that in my new.cpp file, "unexpected end of file while looking for precompiled header directive" error is present, or it reports multiple definitions. :confused: I think you got what I'm trying to do, so pls help me how to set the include graph thorughout my application. Thanx in advance.
#include "stdafx.h"
must be the first#include
of all, always. Apart from this, include the new header in those.cpp
s that require it. If your new module is used by many other parts throughout the libvrary, you can editstdafx.h
and add the#include
there. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
#include "stdafx.h"
must be the first#include
of all, always. Apart from this, include the new header in those.cpp
s that require it. If your new module is used by many other parts throughout the libvrary, you can editstdafx.h
and add the#include
there. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
Ok I see now. new.h includes nothing, new.cpp includes new.h and stdafx.h, and stdafx.h includes new.h. new.cpp is automatically built with other cpps. Thanx again.:-O
gazihan wrote: stdafx.h includes new.h No! stdafx.h includes common header files used by all cpp files Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Buy it, read it and admire me :-)
-
gazihan wrote: stdafx.h includes new.h No! stdafx.h includes common header files used by all cpp files Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Buy it, read it and admire me :-)
-
Hi, I'm a bit new to visual c++ and i'm trying to figure out the right style to create and use new .h and .cpp files in vc++. Say I want to implement a new module of the project in a seperate file. And say I created the new.h and new.cpp files. Now the question is, how should I set the #include lines in the entire project in order to make it work? In new.cpp, I want to use the libraries included in stdafx.h. And in the other parts of the application that stadfx.h is included, I want to use the code that resides in new.cpp. I tried many different ways of including one another but I couldn't find an appropriate one. It either tels me that in my new.cpp file, "unexpected end of file while looking for precompiled header directive" error is present, or it reports multiple definitions. :confused: I think you got what I'm trying to do, so pls help me how to set the include graph thorughout my application. Thanx in advance.
gazihan wrote: "unexpected end of file while looking for precompiled header directive" this error can usually be avoided by changing in Project/Settings/C C++ tab Select a .cpp in the tree left Category : Precompiled Header Set it to Dont'use ... But do not do that for stdafx.cpp of course :) ~RaGE();
-
the stdafx.h has this line: // TODO: reference additional headers your program requires here I want to use new.h in most of the cpp files, so I guess what I did is apropriate.
gazihan wrote: I want to use new.h in most of the cpp files, so I guess what I did is apropriate. Okay! If you are including new.h inside stdafx.h, then do not include new.h in any of your cpp files, since by including stdafx.h you implicitly include new.h as well. Regards Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Buy it, read it and admire me :-)