FIXED:compiling errors...can anyone have a look?
update: fixed thanks everyone
i've been lurking around here for a long while (much longer than since i registered) & been reading about programming since then but laziness pushing me i only started my 1st bigger_than_one_file project last week & didn't even do much
it's very ugly & chaotic & i'm adding code randomly as it feels right (it does nothing for now it's only basic unfinished dx initialization code) but since i added my last class i'm getting an error telling me i'm redefining the constructor & destructor of my class... which i'm not doing (only declared & defined once)
so i assumed it did a quick test & copy / pasted the code from the cpp & h files of that class in a new project with nothing but a main function there & it compiles just fine then & the next step was to try & figure out if i'm not including the file twice but after searching i don't think i am so since it's not directly code specific (making code posting useless) i was wondering if anyone would be so kind to load the project (vs2003) & see if i missed something totally obvious?
thanks to everyone who has a look
[Edited by - ranakor on August 31, 2005 6:59:37 PM]
I havn't looked at your code, but i must ask; are you using fileguards?
I suspect this isn't the problem, but you might aswell put them in if you havn't.
A fileguard can look something like this.
This will ensure that your .h file is only included once/.cpp file you're including it into.
I suspect this isn't the problem, but you might aswell put them in if you havn't.
A fileguard can look something like this.
// this is all put in the .h file#ifndef _WHATEVER_H#define _WHATEVER_H// rest of .h file goes here#endif // at the bottom of your file
This will ensure that your .h file is only included once/.cpp file you're including it into.
Alternatively, if you're using MSVC and are not worried about portability, you can put
#pragma once
at the top of the file [smile]
i'm not using fileguards but i did try fileguards before posting here on dx_renderer.cpp (& moved the content of the corresponding .h inside the cpp at the top to minimize the possibilities of multi inclusions)
as for portability i think it being DX kinda limitates the portability anyway p i'll just stick a pragma once in every .h & let you know if it fixed it
update: not working still & i stuck a #pragma once at the top of every single file in the project beside the main file
as for portability i think it being DX kinda limitates the portability anyway p i'll just stick a pragma once in every .h & let you know if it fixed it
update: not working still & i stuck a #pragma once at the top of every single file in the project beside the main file
You shouldn't be using file guards at all on the .cpp's, only on the .h's. I haven't looked at the code, but keep the .h and .cpp separate like it was originally, and just use a file guard on the .h, since you should only be including .h's in your main project, not the .cpp's.
I looked at the files briefly, try
#ifndef THISFILESNAME_H_
#define THISFILESNAME_H_
as the very first two lines of the .h files, and
#endif
as the very last line in the .h files. The .cpp's seem to be fine.
#ifndef THISFILESNAME_H_
#define THISFILESNAME_H_
as the very first two lines of the .h files, and
#endif
as the very last line in the .h files. The .cpp's seem to be fine.
as i said i put #pragma once at the top of each file & still get the same error=( so don't think it's multiple inclusion anymore
but figured out where i screwed up for some reason my mind totally went flop & the reason i was including lots of cpp was to include both the cpp & h (wich is included in the cpp) totally forgeting that the reason for including the h file was so that i didn't need to include the cpp (have you ever saw such a confusing sentence? think not!) so found the error stubborn_winhandler_win32.h shouldn't be
#include "winhandler_win32.cpp"
#include "winhandler_win32_wndproc.cpp"
#include "stubborn_DX_renderer.cpp"
but
#include "winhandler_win32.h"
#include "winhandler_win32_wndproc.h"
#include "stubborn_DX_renderer.h"
(sorry for not using code tags but i thought that for 3 lines it actually would hurt more than help)
thanks to all who had a look at the code rating ups for everyone
but figured out where i screwed up for some reason my mind totally went flop & the reason i was including lots of cpp was to include both the cpp & h (wich is included in the cpp) totally forgeting that the reason for including the h file was so that i didn't need to include the cpp (have you ever saw such a confusing sentence? think not!) so found the error stubborn_winhandler_win32.h shouldn't be
#include "winhandler_win32.cpp"
#include "winhandler_win32_wndproc.cpp"
#include "stubborn_DX_renderer.cpp"
but
#include "winhandler_win32.h"
#include "winhandler_win32_wndproc.h"
#include "stubborn_DX_renderer.h"
(sorry for not using code tags but i thought that for 3 lines it actually would hurt more than help)
thanks to all who had a look at the code rating ups for everyone
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement