Archived

This topic is now archived and is closed to further replies.

classes reliableness

This topic is 5148 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m currently writing a game in c++, after writing it for a few months, the compiler(m$vcpp6) is starting to mess up my compiled thing. Theres a map class which stores the triangles and has some loading code, when in the function that loads the triangles from the file, the variables in that class are ok, but then when it calls other methods in that class, the variables in the class were screwed up(isnt what it should be) and when i set the function inlining on, it''s normal. I was thinking if it''s better to use a struct for the variables in the class, and make methods outside the class like quake do. Will that save me from those m$ cpp bugs? thanks

Share this post


Link to post
Share on other sites
Without knowing how the classes are defined, and what the calls that are messed up are, there''s no way we can know what''s wrong.
Changing to C instead of C++ isn''t an option, really

Share this post


Link to post
Share on other sites
I am not qualified to ansver your question, but I will attempt to help anyways. Try clearing the compile from the Compile->Clear menu and then recompile. I only say this because that is usualy what solves my problems when my programs react beyond all logic...

"On a long enough timeline the survival rate of everyone drops to zero"
- Fight Club

Share this post


Link to post
Share on other sites
Recompiling didn't help, it even happens in the debug configuration, and to solve it, i have to turn on function inlining, it seems to be a code generation bug, and even intel's c++ compiler has a problem with my game, it screws up my lighting calculation lol

[edited by - Fish HF on November 7, 2003 4:27:48 AM]

Share this post


Link to post
Share on other sites
Stop blaming the compiler and try to find your bugs instead. If your lighting calculations are screwed up, I'm quite certain that it has nothing to do with Intel C++.

[edited by - Dew_LED on November 7, 2003 4:37:35 AM]

Share this post


Link to post
Share on other sites
i'm not blaming intel, it works on m$, except the map loading part fixed by setting function inlining on.
btw i wont post a new topic just because i got a problem that just annoyed me for a day, it affected my development progress for weeks.

[edited by - Fish HF on November 7, 2003 5:09:27 AM]

Share this post


Link to post
Share on other sites
[Continuing with my previous theory]... maybe function inlining causes the variables to be put on the stack in a different place where they don''t get clobbered, and it only appears to be working correctly.

Share this post


Link to post
Share on other sites
Many of these things are possibilities. Especially the one about potentially overwriting your data with an array overflow or wild pointer. Turn of code optimization and see if it runs as expected there, sometimes the compiler optimizes too agressively and breaks things. If that still fails, its most likely bugs in your code.

good luck.

Ravyne, NYN Interactive Entertainment
[My Site][My School][My Group]

Share this post


Link to post
Share on other sites
Make sure you haven''t declared a variable with an equal name in the functions itself. I made this mistake a while ago, and it took me quite a while before I found it.
Also, if you the chance then check the value of the this-pointer.

Share this post


Link to post
Share on other sites
There are bugs in Visual C++ 6 even with sp5 (start here), however the chances of it being a bug in the compiler are about the same as aliens coming from Mars to wipe us all out.

If by some mad chance you have found a bug in the compiler, narrow it down to as small a code fragment as possible and submit it to Microsoft.

Share this post


Link to post
Share on other sites
Your right, it sometimes happen, but now it disappeared...
Isn't vs6 isn't supported anymore? I thought they won't make patches anymore...

[edited by - Fish HF on November 7, 2003 11:07:34 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Fish HF
Your right, it sometimes happen, but now it disappeared...
Isn''t vs6 isn''t supported anymore? I thought they won''t make patches anymore...



I strongly doubt we''ll see any more patches for VC6.
I agree with smart_idiot. You probably have a buffer overrun somewhere.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

Share this post


Link to post
Share on other sites
Fish, could you post a code snippet with the problem? I once had a problem with a struct that used a constructor which wasn''t called for some unknown reason. The moment I changed struct to a class the problem went away. The other problem I had which was entirely my fault was that I used a ''min'' as a name for a function parameter. Took me a while to figure that one out. Those win os macros bite. On unrelated note, I don''t think you should abandon c++ OOP because of your problem. Like some poster said, do a full rebuild of your project and post some code snippets giving you the trouble so we can figure the problem out.

Share this post


Link to post
Share on other sites
Make sure the vector doesn''t have a virtual table pointer in it. It adds 4 extra bytes to the vector which can screw up the vertex stride for the gfx api. Just throwing some ideas around.

Share this post


Link to post
Share on other sites