Write code

In the IDE, you use the C/C++ perspective to develop and build your projects.

The C/C++ perspective

The C/C++ perspective is where you develop and build your projects. Aside from writing code and building projects, you can debug and analyze your apps from the C/C++ perspective.

The views in the C/C++ perspective are driven primarily by selections you make in the C/C++ editor and the Project Explorer view. The Project Explorer view is configured specifically for C and C++ development.

The C/C++ editor is where you write and modify your code. As you work in the editor, the IDE dynamically updates many of the other views (even if you haven't saved your file).

C/C++ editor layout

The C/C++ editor has a gray ruler on each side. The marker ruler might contain icons that indicate errors or other problems detected by the IDE, as well as icons for any bookmarks, breakpoints, or tasks (from the Tasks view). The icons in the left margin correspond to the line of code.

C/C++ Editor layout

Figure 1. The C/C++ editor.

The overview ruler (on the right marign) shows a quick summary of changes in an SVN working copy and other useful information. It shows red and yellow bars that correspond to the errors and warnings from the Problems view. Unlike the left margin, the right margin shows the icons for the entire length of the file.

Assistance with function names

The Content Assist feature can help you finish the names of functions if they're long or if you can't remember the exact spelling.
To use Content Assist:
  1. In the C/C++ editor, type one or two letters of a function's name.
  2. Press Ctrl Space , or right-click near the cursor and select Content Assist.

    A menu with the available functions appears

    C/C++ editor; Content Assist

  3. You can do one of the following:
    • To shorten the list of possibilities, continue typing.
    • To select the function, press Enter.
    • To make a selection from the list of possible options, scroll with the up and down arrows.
    • To select a function, scroll with your mouse. Double-click a function to insert it.
    • To cancel the feature and close the Content Assist window, press Esc.

Access source files for functions

While editing source code in the editor, you can select a function name and press F3, and the editor immediately jumps to the prototype for that function (if the file is also in your project). Or, you can also press CTRL and Click to navigate to the prototype. Additionally, you can navigate to files (such as headers) outside of the workspace (i.e. in the QNX target directories).

Press Ctrl F3, and the editor immediately jumps to the function's implementation (if the file is also in your project).

For more information about the C/C++ perspective, see the link Help > Help Contents in the Workbench User Guide and the C/C++ Development User Guide.

Use hover help

The IDE's hover help feature gives you the synopsis for a function while you're coding.

To use hover help, in the C/C++ editor, hold your pointer over a function. You'll see a text box showing the function's summary and synopsis information:

C/C++ editor; Hover help

Figure 2. Hover help in the C/C++ editor.

In addition, the Macro Expansion hover feature includes a toolbar at the bottom of the control with back, forward, and open declaration buttons. You can also drag the title bar for the Macro Expansion hover box.

Add and remove comments in code

You can easily add comments using either the C or C++ style, even to large sections of code. You can add two forward slash characters (//) at the beginning of lines to comment out large sections, even when they have other comment characters, such as /* */.

When you remove comments from lines, the editor removes the leading // characters from all lines that have them, so be careful not to accidentally uncomment sections. Also, the editor can comment or remove only comments from selected lines — if you highlight a partial line, the editor comments out the entire line, not just the highlighted section.

To comment or remove comments from a block of code:
  1. In the C/C++ editor, highlight a section of code to comment or remove comments. For a single line, position your cursor anywhere on that line.
  2. Right-click and select Comment or Uncomment.

Last modified: 2013-12-21

comments powered by Disqus