C ++, as a powerful computer programming language, helps us easily meet many functional requirements. However, in such language programming, if improperly handled, there will also be some problems. Here we provide an invalid solution for the C ++ breakpoint.
- Basic concepts of C ++ string types
- C ++ parameter transfer
- Connect C ++ to the SQL database in steps
- Basic concepts of C ++ Chinese and English strings
- Basic Content of C ++ namespace
Recently, I encountered a problem where the breakpoint in vs2008 C ++ could not work, as shown below:
1. After a modification, the breakpoint cannot work, and the previous version is still normal
2. the breakpoint in a file cannot work.
3. The Class Object A of the breakpoint is referenced in another DLL.
File structure:
- Core. dll
- A. cpp
- Class
- {
- Public:
- A ()
- {
- Printf ("constructor of ");
- }
- }
- UI. dll
- Manager. cpp
- Class Manager
- {
- Public:
- Manager ()
- {
- Printf ("constructor of Manager ");
- }
- }
- Button. cpp
- A ins; // click the breakpoint here.
- Run.exe
- Void main ()
- {
- Manager ins; // instantiate
- }
It is found that A is not constructed by C runtime before executing main, so the C ++ breakpoint is invalid. The cause of special characters has been ruled out. According to the online method, the file is saved as UNICODE, and the problem persists. Start to use the exclusion and isolation method to determine the problem location, and finally find such a rule:
You only need to construct a Button in Manager. cpp.
Button insB;
After doing so, it is determined that it will certainly work. Therefore, It is inferred that the global structure of the CRT layer needs to be promoted by a linked list. Because the Manager needs to be constructed, the CRT will certainly scan the OBJ corresponding to this CPP to link to the segment in the exe, so that the global constructors in this segment are initialized, but the Button is not used, therefore, it is not constructed. In this way, local scanning should be performed out of efficiency.
Another way to solve the problem of invalid C ++ breakpoint is to use the static link method. In this way, the constructed code is put into the final exe, so that this problem will not occur.