This is a discussion on Visual C++ Tips & Tricks within the C and C++ Programming forums, part of the Software Development category; Thanks for providing the useful informations....
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hey Guys!! I am newbie though not a techie the tip was very useful for my bro . Thnks a ton . Keep posting good ones .... Regards Cathrine Houston Storage Houston Mini Storage Houston Texas Storage Last edited by arjkhanna : 06-29-2009 at 08:33 PM. |
| |||
| Find corresponding brackets Position the cursor over any "{", "[", "(", "}", "]" or ")" bracket and hit CTRL+"]". The cursor will move to the corresponding opening/closing bracket of that expression.
__________________ harshley |
| |||
| Count BPs Stop on the Nth iteration To Help find N: Set BP w/ very large count (C==10000) Run until your app crashes Look at count value (X) Set count BP on C-X-1 By Name Stays put through edits (as opposed to F9, for file/line number BPs) Memory Leaks Docs are confusing Indexed entries talk about MFC No clear description Go to "Visual C++ Documentation/Using Visual C++/Visual C++ Programmers Guide/Debugging/Debugging Techniques.Problems and Solutions/Solving Buffer Overwrites and Memory Leaks" (6.0) Include order is important Some things redefine malloc and free, etc. Step 1, include in global header file #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> Step 2, enable checks in WinMain: // Enables tracking and reporting on shutdown. _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); _CrtSetReportMode ( _CRT_ERROR, _CRTDBG_MODE_DEBUG); It may list file/line number Will list leak number set {,,msvcrtd.dll}_crtBreakAlloc = n (leak number) Or, look for ASCII clues. Memory Corruption Heap Corruption Enable heap checking (slow) {,,msvcrtd.dll}_crtDbgFlag = 5 Data BPs may be useful Optimized Code It's hard Compile with /Zi Variables vanish or are wrong Use disassembly window for truth Arguments usually OK except this fastcall Just find your bugs in Debug! 8) Casting in the debugger Need correct type name Debugger doesn't know typedefs To find the true typename, Add variable to watch, RClick, choose properties Scoping: variable defined in current DLL, type defined in another DLL: {,,foo.dll}(CMyClass *){*}pObject pObject is local, CMyClass defined in foo.dll Modules Window Debug.Modules Sort by: Module name Address range Useful for finding out what module you're in Find DLL of EIP Full path Ensure you're using the correct DLL Load order (default)
__________________ harshley |
| |||
| // Statements like: // #pragma message(Reminder "Fix this problem!") // Which will cause messages like: // C:\Source\Project\main.cpp(47): Reminder: Fix this problem! // to show up during compiles. Note that you can NOT use the // words "error" or "warning" in your reminders, since it will // make the IDE think it should abort execution. You can double // click on these messages and jump to the line in question. #define Stringize( L ) #L #define MakeString( M, L ) M(L) #define $Line \ MakeString( Stringize, __LINE__ ) #define Reminder \ __FILE__ "(" $Line ") : Reminder: "
__________________ harshley |
| |||
| // Statements like: // #pragma message(Reminder "Fix this problem!") // Which will cause messages like: // C:\Source\Project\main.cpp(47): Reminder: Fix this problem! // to show up during compiles. Note that you can NOT use the // words "error" or "warning" in your reminders, since it will // make the IDE think it should abort execution. You can double // click on these messages and jump to the line in question. #define Stringize( L ) #L #define MakeString( M, L ) M(L) #define $Line \ MakeString( Stringize, __LINE__ ) #define Reminder \ __FILE__ "(" $Line ") : Reminder: " Once defined, use like so: #pragma message(Reminder "Fix this problem!") This will create output like: C:\Source\Project\main.cpp(47): Reminder: Fix this problem!
__________________ harshley |
| |||
| I know how to program in Turbo C++ but never used the knowledge, so now i need to review and re-study so i can go back in programming world. The tips and tricks that you have shared is very helpful to me. Thanks |
| |||
| I learned C language when i was still in college but sadly never used my knowledge in programming for a long time. So, right now i am refreshing my knowledge about it and your tips well help me a lot.
__________________ weight loss pills |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C# .Net Tips & Tricks | oxygen | C# Programming | 85 | 01-08-2009 12:25 AM |
| SAP Tips & Tricks | leoraja8 | Operating Systems | 0 | 03-29-2008 12:11 AM |
| Visual Studio Tips & Tricks | SaravananJ | C# Programming | 197 | 12-20-2007 03:25 AM |
| .NET tricks & Tips | Karpagarajan | VB.NET Programming | 1 | 04-23-2007 08:17 AM |
| SEO Tips & Tricks | spid4r | Search Engine Optimization | 0 | 03-08-2007 11:03 PM |
Our Partners |