C ++ breakpoint invalid Solution

Source: Internet
Author: User

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:

 
 
  1. Core. dll
  2. A. cpp
  3. Class
  4. {
  5. Public:
  6. A ()
  7. {
  8. Printf ("constructor of ");
  9. }
  10. }
  11. UI. dll
  12. Manager. cpp
  13. Class Manager
  14. {
  15. Public:
  16. Manager ()
  17. {
  18. Printf ("constructor of Manager ");
  19. }
  20. }
  21. Button. cpp
  22. A ins; // click the breakpoint here.
  23. Run.exe
  24. Void main ()
  25. {
  26. Manager ins; // instantiate
  27. }

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.

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.