🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

A few questions.

Started by
4 comments, last by sherman 24 years, 5 months ago
I have a few questions that I have somehow manage to procrastinate asking until now. They have been really been bugging me so I will greatly appreciate it if any of you can help me. 1. I have been doing most of my debugging (MS Visual C++) using message boxes all this while. I know it is really lame and is not suitable for my large source files these days, so how do I debug professionally? Previously, I used debug windows in Turbo C++ to keep track of my variables but how do I do it with VC++? I even have problems stepping through my code since VC++ usually tells me that it needs some header file before it reverts to assembly. 2. Is there a way to dynamically allocate arrays in C? I know you can do that with C++''s new but how about C? I have been using linked list all this while but I guess it is a little slow. 3. Are there any other game programmers from Malaysia on this message board? If there are, please reply - just out of curiosity. 4. Oh great, I forgot again but I will be sure to ask when I remember. Thank you. Best regards, Sherman
_________________ Best regards, Sherman Chin Director Sherman3D (Malaysia) Sdn Bhd www.Sherman3D.com www.AlphaKimori.com
Advertisement
1) I know MSVC asks for source file locations so it can display the source code as you debug... you definately want to give it what it asks for. I believe you can still use the watch windows even in assembly code, but I've never had a reason to try it. 99% of the time the compiler will never ask you for source file locations... if it's continually asking you for stuff, you might want to look at how your project/workspace are set up.

Regardless of that tho, if you're using MFC, check out the TRACE() macro. If you're not using MFC, I believe there are other ways to get a string into the MSVC output window, but I don't remember exactly how (DebugPrint?)

2) Yes, using malloc. Say you want to create an array of five ints:

int *array = (int *)malloc(5*sizeof(int));
array[0] = 1;
array[1] = 2; ...

Or, five structs:

typedef struct { ... } MYSTRUCT;
MYSTRUCT *array = (MYSTRUCT *)malloc(5*sizeof(MYSTRUCT));

Hope it helps -

Mason McCuskey
Spin Studios - home of Quaternion, 2000 GDC Indie Games Fest Finalist!
www.spin-studios.com

Edited by - mason on 1/19/00 12:38:57 PM
Founder, Cuttlefish Industries
The Cuttlefish Engine lets anyone develop great games for iPad, iPhone, Android, WP7, the web, and more!

OutputDebugString( char* );

Will output the string to the debugger, of course it doesn''t have the nifty formatting feature that the TRACEx macros do, but there are ways to get around that..

-mordell
__________________________________________

Yeah, sure... we are laughing WITH you ...
Thank you mason and mordell.
Mason, I am doing Win32/DirectX programming and I guess I am pretty ignorant since I don''t even know the basics of getting a watch window up. How do I do it? It was pretty easy in Turbo C++ but VC++ is totally confusing. As for the constant 5 (your second answer), is it possible to allocate a variable that is determined at runtime?
Mordell, what advantage has OutputDebugString that a messagebox hasn''t?
Thank you.
_________________ Best regards, Sherman Chin Director Sherman3D (Malaysia) Sdn Bhd www.Sherman3D.com www.AlphaKimori.com

Well...it can get pretty tiring clicking [OK] for all those messagebox''s!

I guess its just personal preference. MSVC has a really nice debugger built in. You can set watches, breakpoints, etc..

I think where you may be having trouble "stepping" in MSVC is trying to step into either a system or library function. For those instances, "step over" [F10] and when you want to "step into" your code, press [F11].

You can set breakpoints by placing the cursor on the line you want and hitting [F9].

You can add a watch by right clicking on a variable...or hightlighting and dragging into your watch window.

This should all be covered pretty well in the documentation.

Good luck!

-mordell

__________________________________________

Yeah, sure... we are laughing WITH you ...
Thanks again, Mordell. That really helped. I didn''t know how to use the watch windows at all and was too lazy to check the documentation

Best regards,
Sherman
_________________ Best regards, Sherman Chin Director Sherman3D (Malaysia) Sdn Bhd www.Sherman3D.com www.AlphaKimori.com

This topic is closed to new replies.

Advertisement