[Reprinted] Visual C ++ development tools and debugging skills

Source: Internet
Author: User
Tags microsoft help
I always use the VC platform to develop things, but sometimes this problem always occurs, here, I 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 to debug in the Release status
Project-> Setting => ProjectSetting dialog box, select the Release status. In the C/C ++ label, select General for Category, Disable (Debug) for Optimizations, and Program Database for Debut info. Select the Generate debug info check box in the Link label.

Note: It is only an intermediate state between Debug and Release, and all ASSERT and VERIFY do not work. The function call method is actually called, rather than the table, however, in this status, the QuickWatch and call queue tracking functions are still effective, just like the Debug version.

2. What is the difference between Release and Debug?
The Release version is called the Release version, and the Debug version is called the Debug version.
Debug can be executed and tracked in one step, but the generated executable file is relatively large, and the code runs slowly. Release runs fast and has a small executable file, but cannot execute the debugging function under the compiling conditions.
The Release exe file is linked to the Standard mfc dll (Use MFC in a shared or static dll ). These DLL have been configured during Windows installation, so these programs can run on machines without Visual C ++ 6.0 installed. The Debug version exe is linked to the Debug version of the mfc dll file and cannot be run on a machine without Visual C ++ 6.0 installed, because the corresponding DLL is missing, unless you select use static dll when link.

3. What is the difference between ASSERT and VERIFY?
The content in ASSERT is not compiled in the Release version. VERIFY still translates the content, but does not judge whether the content is true or false. Therefore, the latter is safer.
For example, ASSERT (file. Open (strFileName )).
Once in the Release version, this line is ignored, and the file is not Open () at all, and there is no error message. If VERIFY () is used, this problem will not occur.

4. What is the relationship between Workspace and Project?
Each Workspace can contain several projects, but only one of them is in the Active state. Each project can have dependencies .. for example, the Active project can depend on other static libraries that provide function calls.

5. How to Use ClassWizard in a non-MFC Program
Create an empty. RC file in the project directory and add it to the project.

6. How to set breakpoints
Press F9 to add a breakpoint and cancel a breakpoint at the current cursor.
In addition, press Ctrl + B to bring up the breakpoint Settings dialog box. Then click [Condition ...] Click the button to bring up a dialog box to set the breakpoint conditions.

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 a bug in the current Visual C ++ 6.0 version. You can follow the steps below to make it normal. If it appears again, it can be processed as follows:
(1) Close the Project
(2) Delete the "Project name. ncb" File
(3) re-open the project

8. How to completely delete a class generated by ClassWizard
First, select. h and. to delete the cpp file, press delete to delete it, delete the two files in the file manager, and then run ClassWizard. If you want to remove the files, select remove.

9. How to Find the classes that disappear in workspace
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
Choose Edit> Breakpoints ...], Open the Breakpoints dialog box and click Remove All. The shortcut key is "Ctrl + Shift + F8 ".

11. How to Select Unlisted Information in ClassWizard?
Open the "ClassWizard" dialog box and switch to the "Class Info" page. Change "Message filter". For example, if "Window" is selected, Window information will appear on the "Message" page.

12. How to check whether parentheses in the 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 the definition of a macro (or variable or function)
Move the cursor to a macro to be viewed. For example, on the most common DECLARE_MAP_MESSAGE, click F12 (or right-click the relevant menu in the menu). If a Browser file is not created, a prompt dialog box is displayed, click OK, and the macro (or variable, function) will jump to the defined place.

14. How to add a Lib file to the current project
Choose Project> Settings ...] In the displayed "Project Setting" dialog box, switch to the "Link" tab, enter the Lib file name in "Object/library modules", and use a blank space for different Lib files.

15. How to quickly delete temporary files in the Debug folder of a project
In the FileView view of the workspace, select the corresponding project, right-click the pop-up menu, and select the Clean (selection only) menu.

16. How to quickly generate a new project with identical project names
In the New project dialog box, select Custom Appwizard, enter the name of the New project, and click OK. The Custom AppWizard item appears. enter the name of the new project and click OK. In the Custom AppWizard-Step 1 of 2 dialog box, select An existing Project and click Next. The Custom AppWizard-Step 2 of 2 dialog box appears. Select the project file name of the existing project and click Finish. After compilation, a project AppWizard that is the same as the existing project but can be renamed again is generated.
Now you can use the customized Wizard like the MFC AppWizard. If you do not want to use it, you can delete the. awx and. pdb files corresponding to the Wizard in the Common \ MSDev98 \ Template directory under the Visual C ++ 6.0 installation directory.

17. How to Solve the Problem of incorrect connection to Visual C ++ 6.0
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 future file (the modification time and creation time are later than the system time. You can do this: Find the debug directory under the project folder, delete All files created and modified at a time later than the system time, and then Rebuild All again.

18. What are common errors that cause LNK2001?
The main LNK2001 error is: 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. The following are possible causes of LNK2001 errors:
<1> LNK2001 error caused by an Encoding Error
(1) mismatched program code or module definition (. DEF) file causes LNK2001. For example, if a variable "var1" is declared in the C ++ source file, but the variable "var1" is attempted to access the change volume in another file.
(2) If the inline function is defined in the. cpp file, rather than being defined in the header file, LNK2001 errors will occur.
(3) When calling a function, if the parameter type used does not match the type declared in the header function, LNK2001 error will occur.
(4) LNK2001 error will occur when you attempt to call a virtual function from the constructors or destructor of the base class.
(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. A compilation error or LNK2001 error occurs when you try to obtain any static variables not declared in the file from outside the file.
<2> LNK2001 errors caused by compilation and connection settings
(1) If the/NOD (/NODERAULTLIB) option is used during compilation, the Runtime Library and MFC required by the program will be written into the target file module by the compiler, however, these libraries will not be linked to the project file unless they are explicitly included in the file. In this case, using/NOD will cause LNK2001 errors.
(2) If no program entry is set for wWinMainCRTStartup, the "unresolved external on _ WinMain @ 16" LNK2001 error message will appear when Unicode and MFC are used.
(3) When compiling with the/MD option, since all the runtime libraries are kept in the dynamic link library, reference "_ imp _ func" in the target file. If you try to use the static library LIBC. LIB or LIBCMT. LIB for Link, LNK2001 error will occur on _ imp _ func. If you do not use the/MD option for compilation, the LNK2001 error will also occur when you use the MSVCxx. LIB link.
(4) When compiling with the/ML option, if LIBCMT. LIB is used, the LNK2001 error will occur on _ errno.
(5) When compiling and debugging an application, if you use the release modal library for link, the LNK2001 error will also occur. Similarly, the same error occurs when you use the debug modal library to link the release application.
(6) mixed use of libraries and compilers of different versions can also cause problems, because the new library may contain symbols and descriptions not available in earlier versions.
(7) using inner and non-inline compilation options in different modules can cause LNK2001 errors. If function inline (/Ob1 or/Ob2) is enabled when the C ++ library is created, but function inline (no inline keyword) is disabled in the header file that describes the function ), only the error message is returned. To avoid this problem, the inline keyword should be marked as an inline function in the corresponding header file.
(8) Incorrect/SUBSYSTEM or ENTRY settings can also cause LNK2001 errors.

19. How to debug a dll called by an exe file without source code
In Visual C ++ 6.0, go to the Project Setting Dialog Box and select the Debug tab. Generally, Visual Studio uses "executable for debug session" by default as the executable file name, but you can change it to any program you want. You can even specify different working directories and PASS Parameters to your program. This technique is often used to debug Dlls, namespace extensions, COM objects, and other plug-in programs called from certain EXE and third-party EXE.

20. What do the project files in Visual C ++ 6.0 Project represent?
. Opt: parameter file of the project about the development environment. Such as the tool bar position and other information.
. Aps (AppStudio File) is a resource auxiliary File in binary format. You do not need to worry about it.
. Clw: ClassWizard information file is actually in the INI file format. If you are interested, please study it. Sometimes the ClassWizard has a problem. You can manually modify the CLW file to solve the problem. If this file does not exist, you will be prompted whether to re-create it each time you use ClassWizard.
. 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 are similar to. dsp.
. Plg: it is a compilation information file. The error and warning information files during compilation (actually an html file) are generally of little use. In the dialog box that appears, choose Tool> Option to control file generation.
. Hpj (Help Project): a Project that generates a Help file, which can be processed by microsoft Help Compiler.
. Mdp (Microsoft DevStudio Project): It is an earlier version of the Project file. To open this file, you will be prompted to convert it to a new. dsp format.
. Bsc: Used to browse project information. This file is required if Source Brower is used. If you do not need this function, you can remove the Generate Browse Info File in Project Options to speed up compilation.
. Map is the image information record file of the execution file. This file is generally not required unless it is at the underlying level of the system.
. 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 Program-related data and debugging information, which may be useful during debugging.
. Exp: it is generated only when the DLL is compiled. It records some information about the DLL file and is generally useless.
. Ncb: no compile browser ). You can delete this file when the Automatic completion function fails. The project is automatically generated after compilation.

Related Article

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.