Select the major elements of the C ++ Editor

Source: Internet
Author: User
Tags gcov thread stop

The C ++ compiler has been bundled with another editor and other programs into an interactive development environment IDE for C ++ development, the first thing is to select a suitable C ++ editor. The C ++ editor has the following elements:

1) Reduce Unnecessary editing actions and reduce the editing time. All editing tasks that can be described without ambiguity can and should be automated. For example, every C ++ program has a main function. when importing a file, you want to add some pre-processing commands # define to help us solve the trouble of repeatedly referencing the same header file.

Mouse operations are always slower than keyboard operations. In this regard, EMACS is doing its best. Therefore, EMACS users often boast that their editing speed is the same as their thinking speed.

2) high scalability.
The programmer's expected C ++ editor should be able to provide some programming help, such as syntax highlighting, Automatic completion, automatic layout, and syntax check. Take a look at gedit, vim, emacs, and ultraEdit, and you will find that they provide far less simple functions than windows notepad.

For a new language and new syntax, they should be easily supported without stopping in one or more fixed languages.

3) highly customizable users.
If you want to work on R & D for a long time, especially in linux/unix, you need to learn a C ++ editor with sufficient functions. There is one sentence: There are three types of programmers in Linux: emacs, vi, and others.

EMACS is a gpl c ++ editor written by Stallman in lisp. The emacs mentioned here refers to GNU emacs, not Xemacs. Because of its openness, we can build it into a powerful IDE. After CGYwin is installed, EMACS can also be used in Windows. CGYwin and MINGW are third-party tools for simulating POSIX systems on Windows.

EMACS is not so much a C ++ editor as an operating system. We can use it to write programming, write wiki, send and receive emails, and so on. EMACS is extended in two ways: el script (elisp is a dialect of lisp) and third-party extension package. EMACS has a high entry cost.

Gccgnu compiler collection is preferred for C ++ compilers ). There are two reasons: it is open-source by GNU, and it supports up to 96.15% of Standard C ++. The support of VC ++ 6.0 is only 83.43%. GCC is not only a C or C ++ compiler in the general sense, but also can compile other languages such as java. Gcc is the c ++ Compiler of gnu C, and g ++ is the c ++ Compiler of gnu C ++, while EGCS (Enhanced GNU Compiler Suite) can be considered as the release version of gcc.

We can use a compilation command to complete all the steps. It can also be executed step by step. Gcc has three important options:-E (preprocessing only),-S (generating assembly code), and-g (generating executable files with the original code debugging symbol, if you want to use gdb for debugging, you should enable this option during compilation ).
GCC can be considered as a software package. In addition to the compilation tool, it also integrates the Debugger gdb, the performance analysis tool gcov, and gprof.

As long as GCC is installed, these powerful tools can be used directly. With gcov, we can view the number of times each line of code runs in the source code of a program. We can optimize the program by optimizing the code that runs the most frequently. When using gcov, You need to enable the fprofile-arcs and ftest-coverage options of GCC. Common options in gcov include-B branch statistics.

With the gprof tool, we can view the call sequence between functions and the running time of each function. We can understand gprof as an enhanced version of the linux/unix built-in tool time. When using gprof, you must enable the pg option of GCC.

What gcov and gprof have in common is to add some auxiliary information to compile the program for program diagnosis. In addition to these optimization methods, we can also use some memory leak tools to reduce wild pointers and unreleased memory space.

  • Introduction to C ++ features
  • Mechanism Analysis of C ++
  • Instructions on C/C ++ header files
  • Is the C ++ language really so hard to learn?
  • How to compile C ++ Code better and faster

GDB is the GNU Debugger. It is a high-performance Debugger Attached to GCC. Through the combination of GDB and script, we can implement regression testing well.
GDB can run in CLI and GUI modes.

By default, GDB is in CLI mode. You can download and install GDB in GUI mode, such as xxgdb and ddd. A better way is to use GDB in EMACS.

The C ++ editor includes all the debugging functions of the visual studio tool and functions that it does not have. In addition to support, we generally set breakpoints, single-step tracking, step in, step out, step over, and other powerful functions. In gdb, we can have the following pause Methods: BreakPoint), observation point WatchPoint), capture point CatchPoint), signal Signals), Thread stop Thread Stops ).

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.