MS Visual C++ Advice

Started by
54 comments, last by johnnyboy 21 years, 4 months ago
> visual studio.net does not need a runtime.
I wrote an SDL app (=> needs MT DLL CRT) using VC7, and it demands msvcr70.dll, instead of the msvcrt.dll that''s present on every version of Windows I''ve seen.
Why?! Looking at the CRT source (gaarggh), I don''t think they''ve changed anything significant (yep, same old BASIC rand(), Pentium ''optimized'' memcpy() complete with U/V pairing).

> win2000/winXP are very stable. if the app crashes, its _your_ fault. win98 is not that stable.
As to stability: is cussing MS because a) their PE documentation is somewhat lacking b) ''different'' header values consistently crash the system (silent reboot even) "m$ bashing"?
Oh, almost forgot the printf("\b\b") thing (bug in csrss kills the NT kernel. I''d love to hear that one explained).
Better than 9x though

BTW, I find the "m$ suxx0rs" people somewhat more tolerable: they usually have the evidence/facts on their side.

quote:coding with api''s, like dx,gl,win32, etc can mean you get crashes not wrong done by you, bugs that where not your fault. except one thing: they are about all documented. so its your fault if you did not knew about them.

I''d rather they were fixed, before they''re immortalized by crazy workarounds / reliance on the bug


> the most important thing: just code. you learn it all by yourself. you don''t learn if you don''t make the fault. believe me. <
Although after hours of tearing your hair out, you will likely never make the same mistake again, there are much nicer ways of learning things.
For example, I was very grateful for (and learned a lot from) Mark Kilgard''s _19 common OpenGL pitfalls_; I believe he was asking for something along those lines.


> You were asking us to do something unreasonable
1) us?
2) unreasonable?
3) Thinking about something constructive to say would probably have been a better investment of time than pissing and moaning / flaming the guy about how he asked the question (hrrn, applies to me too? ).

> Either that or your too stupid to know a good suggestion from a bad suggestion (which, believe it or not, is very common amongst newbies <
That''s probably true, but usually not because the person in question is "stupid".

Teodric: thanks for the insightful+helpful reply! S/N increased

now some suggestions of my own: this is a pretty short list, ''cause it''s 0300 and my memory is AWOL.
1) beware of mixing CRT versions in different source files / the project settings (grr, that one was embarassing + a huge waste of time)
2) on a similar note, don''t assume a particular app/DLL was compiled with the same runtime as yours (can''t use static library data).
3) if you mix up your project settings (console vs Win32), or want / don''t want main() / a console, all is not lost: change entry point in Linker options, output (advanced for .net) to mainCRTStartup and add linker option /SUBSYSTEM:CONSOLE
4) VC6 often messes up precompiled headers. Make sure all files but precompiled.cpp ''use'' the header, and have precompiled.cpp ''create'' it; also, anything in a source file before "precompiled.h" is ignored.

Maybe those are documented somewhere; I don''t have a problem reading about specific functions, but sometimes you have to know about the existence of the problem
As Kilgard put it:
quote:I hope that this review of various OpenGL pitfalls saves you much time and debugging grief. I wish that I could have simply read about these pitfalls instead of learning most of them the hard way
E8 17 00 42 CE DC D2 DC E4 EA C4 40 CA DA C2 D8 CC 40 CA D0 E8 40E0 CA CA 96 5B B0 16 50 D7 D4 02 B2 02 86 E2 CD 21 58 48 79 F2 C3
Advertisement
Here''s what I can think of:
- Security priviledge differences on Win98 and NT-based.
- Always have the latest patch on the OS and the IDE
- Always keep copies of previous working project''s versions
- RAII saves hours of debugging
- const-reference is very special...
- Know the difference between executable''s pathname and current working folder
- Sometimes (rarely) a Rebuild-All could take away all the compiler errors
- Know the order of how include files are searched
- over commenting... writing essay instead of coding
"after many years of singularity, i'm still searching on the event horizon"
jan: thanks, yes, that is the kind of stuff I am looking for!

I''ll check out/see if I can find that book by Mark Kilgard
!
> I''ll check out/see if I can find that book by Mark Kilgard
Grab it here: Link
E8 17 00 42 CE DC D2 DC E4 EA C4 40 CA DA C2 D8 CC 40 CA D0 E8 40E0 CA CA 96 5B B0 16 50 D7 D4 02 B2 02 86 E2 CD 21 58 48 79 F2 C3
I would post the errors I''ve come across but I would hate to take that experience from you. Tell you what, just get started programming and if you have errors that you can''t seem to figure out, post those along with your source and someone will help you figure it out. You''ll find you get a lot more done and spend less time argueing with people on forums.
Some good advice has been given out which i''d like to reiterate:

- Get used to using the debugger in VC++. It''s absolutely fantastic for problem solving.

- There are some excellent books out there that will teach you how to spot common errors as you go along. For windows programming in VC++ I recommend


  • Programming Windows by Charles Petzold
  • Begining Visual C++ 6 by Ivor Horton


  • These books are informational gold!

    For DX8 I recommend the Prima Press game programming series. I have got:


  • Zen Of Direct3D Game Programming by Peter Walsh
  • Special Effects Game Programming by Mason McCuskey
  • Multiplayer Game Programming by Todd Baron


  • I have just bought the role playing one but haven''t started it yet ... I now feel competant enough to start programming a 3D game engine with good coding practices in MS VC6++

    Regards

    RayWilson

    This topic is closed to new replies.

    Advertisement