Visual c ++ development and debugging skills

Source: Internet
Author: User
Tags microsoft help
Visual c ++ Development tools and debugging skills Always use VC The platform is used to develop things, but sometimes such problems always occur. , Here, we will extract some tips for using the Internet Lookup as follows: , I hope it will be useful to you, saving you the trouble of searching again. 1. How Release Status for debugging Project - > Setting = > Projectsetting Dialog box,Select Release Status . C/C ++ Tag In Category Select General , Optimizations Select Disable (Debug) , Debut info Select Program database . In Link Tag MediumSelected Generate debug info Check box . Note: It's just a question Debug And Release The intermediate status of all Assert , Verify It does not work. The function call method is already a real call, but does not look up the table, but in this status Quickwatch , The call queue tracking function is still valid, and Debug Same version. 2. Release And Debug What is the difference? Release The version is called the release version, Debug The version is called the debug version. Debug But the generated executable file is large,CodeThe running speed is slow. Release The version runs fast and the executable file is small, but the debugging function cannot be executed under the compiling conditions. Release Of EXE File links are standard Mfc dll (use MFC in a shared or static DLL) . These DLL Install Windows , So theseProgramCan be installed Visual c ++ 6.0 . While Debug Version EXE Link to the debug version MFC DLL File. Visual c ++ 6.0 Cannot run on the machine, because the corresponding DLL Unless you select Use static DLL when Link . 3.   Assert And Verify What is the difference? Assert Content in Release Version is not compiled, Verify The content is still translated, but it is no longer true or false. Therefore, the latter is safer. For example Assert (file. Open (strfilename )) . Once Release In version, this line is ignored, File Not at all Open () And no error information. If you use Verify () This problem will not occur. 4. Workspace And Project What is the relationship between them? Each Workspace It can include several Project , But only one Active Status, each Project There can be dependency between, in Project Of Setting .. Can be set, such as Active Status Project You can rely on other static libraries that provide function calls. 5. How MFC Used in the program Classwizard Create an empty . RC File, and then add it to the project. 6. How to set breakpoints Press F9 Add a breakpoint and cancel a breakpoint at the current cursor. In addition, in the editing status, press CTRL + B Key combination. the breakpoint Settings dialog box is displayed. Then click 【 Condition... . 7. In the editing status, the member variables or functions cannot be displayed, prompting you how to enable the display function. This seems to be the current Visual c ++ 6.0 One version Bug , You can follow the steps below to make it normal. If it appears again, it can be processed as follows: (1) Close Project (2) Delete " Project name . NCB" File (3) Re-open the project 8. How Classwizard The generated class is permanently deleted. First FileView Select . H And . Cpp File, press Delete Delete, delete the two files in the file manager, and then run Classwizard If you want to remove the class, select Remove You can. 9. How Workspace Find the class that disappears in Open the header file corresponding to the class, and change its class name. A new class will appear in the workspace, and then change the class to its original name. 10. How to clear all breakpoints Menu 【 Edit ]- > 【 Breakpoints... ], Open "Breakpoints" Dialog box, click 【 Remove all ] Button. The shortcut key is "Ctrl + Shift + F8" . 11. How Classwizard Select information not listed in Open "Classwizard" Dialog box, and then switch "Class Info" Page. Change "Message filter" , For example, select "Window" , "Message" The page appears. Window . 12. How to check whether parentheses in a program match Move the cursor to the bracket to be checked and press the shortcut key "Ctrl +]" . If the brackets match correctly, the cursor jumps to the matching brackets. Otherwise, the cursor does not move and the chassis horn generates a warning. 13. How to view a macro ( Or variables and functions ) Definition Move the cursor to a macro to be viewed, for example, the most common Declare_map_message Click F12 ( Or right-click the relevant menu in the menu ) If a browse file is not created, a prompt dialog box is displayed. Click OK and the macro is displayed. ( Or variables and functions ) Definition. 14. How to add Lib File to current project Click menu 【 Project ]- > 【 Settings... ] Pop-up "Project setting" Dialog box, switch "Link" Tab, in "Object/library modules" Enter Lib File Name, different Lib Use an empty grid to separate the two. 15. How to quickly delete Debug Temporary files in the folder In the workspace FileView Select the corresponding project in the view, right-click the pop-up menu, and select 【 Clean (selection only) ] Menu. 16. How to quickly generate a new project with identical project names In "New" Select "Custom Appwizard" Item, enter the name of the new project, and click 【 OK ] Button. Appears "Custom Appwizard" Item, enter the name of the new project, and click 【 OK ] Button. Appears "Custom Appwizard - Step 1 of 2" Dialog box, select "An existing project" Item, click 【 Next ] Button. Appears "Custom Appwizard - Step 2 of 2" Dialog box, select the project name of the existing project, and click 【 Finish ] Button. After compilation, a project that is the same as the existing project but can be renamed again is generated. Appwizard . Now you can use MFC Appwizard Use this custom wizard. If you do not want to use it, you can Visual c ++ 6.0 Under the installation directory Common/msdev98/template Delete Wizard Corresponding . Awx And . PDB File. 17. Solution Visual c ++ 6.0 Incorrect connection Scenario: if a file is changed, the entire project must be re-compiled and linked once. Just now the link is ready for operation, and the system prompts you to re-compile the link once. This is because of the emergence of future documents. ( The modification time and creation time are later than the system time. ) . You can do this: Find Debug Directory, delete all files created and modified at a time later than the system time, and then "Rebuild all" Once. 18. Cause Lnk2001 Which of the following are common errors? Encountered Lnk2001 Errors mainly include: Unresolved external symbol "symbol" This error message is returned if the linked program cannot find the referenced function, variable, or tag in all libraries and target files. Generally, there are two reasons for the error: one is that the referenced function or variable does not exist, the spelling is incorrect or the usage is incorrect; the other is that different versions of the Link Library may be used. Below are possible Lnk2001 Cause of error: <1> Encoding Error Lnk2001 Error (1) Unmatched program code or module definition (. Def) File causes Lnk2001 . For example C ++ The source file declares a variable. "Var1" In another file "Var1" The amount of access changes. (2) If the inline function is . Cpp Defined in the file, rather than in the header file. Lnk2001 Error. (3) When a function is called, if the parameter type used does not match the type declared in the header function Lnk2001 Error. (4) When you try to call a virtual function from a base class constructor or destructor Lnk2001 Error. (5) Pay attention to the availability of functions and variables. Only global variables and functions are public. Static functions and static variables have the same scope of use. Compilation errors or Lnk2001 Error. <2> Caused by compilation and connection settings Lnk2001 Error (1) If you use /Nod (/noderaultlib) Option, the required Runtime Library and MFC The compiler will write the library into the target file module, but these libraries will not be linked to the project file unless they are explicitly included in the file. In this case /Nod Will cause Lnk2001 Error (2) If Wwinmaincrtstartup Set the program entry. Unicode And MFC Will appear "Unresolved external on _ winmain @ 16" Of Lnk2001 Error message. (3) Use /MD In the source file "Func" In the target file, that is "_ Imp _ FUNC" . If you try to use a static library Libc. Lib Or Libcmt. Lib In _ Imp _ FUNC Occurs on Lnk2001 Error. If you do not use /MD Option compilation, in use Msvcxx. Lib Link will also happen Lnk2001 Error. (4) Use /Ml For example Libcmt. Lib The link will be in _ Errno Occurs on Lnk2001 Error. (5) When compiling and debugging an application, if you use the release modal library for link Lnk2001 Error. Similarly, the same error occurs when you use the debug mode library to link the release application. (6) Mixed use of libraries and compilers of different versions can also cause problems, because the library of the new version may contain symbols and descriptions not available in earlier versions. (7) Using inline and non-inline compilation options in different modules can result in Lnk2001 Error. If you create C ++ Function inline is enabled in the library. (/Ob1 Or /Ob2) But function inline is disabled in the header file that describes the function. ( No Inline Keywords ) Only the error message is returned. To avoid this problem, use the corresponding header file Inline The keyword flag is an inline function. (8) Incorrect /Subsystem Or Entry Setting can also cause Lnk2001 Error. 19. How to debug a project without source code EXE File called DLL In Visual c ++ 6.0 , Go "Project setting" Dialog Box and select Debug Tab. Usually Visual Studio Default "Executable for debug session" It can be an executable file name, but it can be changed to any program you want. You can even specify different working directories and PASS Parameters to your program. This technology is often used for debugging. DLLs , Namespace extension, Com Objects and others EXE And from a third party EXE Called in Plug-in Program. 20. Visualized C ++ 6.0 What do project files represent? . Opt : Parameter file of the project about the development environment. Such as the tool bar position and other information. . APS (appstudio file) Resource auxiliary file in binary format. . CLW : Classwizard The information file is actually Ini File Format. If you are interested, please study it. Sometimes Classwizard An error occurred. manually modify it. CLW File. If this file does not exist Classwizard Then, the system prompts whether to re-create the image. . DSP (developstudio Project) : Project file, text format, but do not modify it manually if you are not familiar with it. . DSW (developstudio workspace) : It is a workspace file. Other features and . DSP Similar. . PLG : Indicates the information file to be compiled. Error And Warning Information File ( Is actually Html File ) Generally, it is of little use. Click 【 Tool ]- > 【 Option ] The pop-up dialog box contains an option to control the generation of this file. . HPJ (Help Project) : A project that generates a Help file. Microsoft Help Compiler Yes. . MDP (Microsoft devstudio Project) : It is an old project file. If you want to open this file, you will be prompted to convert it into a new one. . DSP Format. . BSC : Used to browse project information. Source brower This file is required. If you do not need this function, you can Project Options Remove Generate browse info file To speed up compilation. . Map Is the image information record file of the execution file. Unless it is at the underlying level of the system, this file is generally not needed. . PCH (pre-compiled file) : It is used to compile files, which can speed up compilation, but the file size is very large. . PDB (Program database) : Records some program-related data and debugging information, which may be useful during debugging. . Exp : Only after compilation DLL It is generated and recorded. DLL File Information, which is generally useless. . NCB : No compiled browsing File (No compile browser) . You can delete this file when the Automatic completion function fails. The project is automatically generated after compilation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.