CODEBLOCKS IDE

CodeBlocks IDE Overview

The IDE (Integrated Development Environment) in JumpStart C++ is based on the open source CodeBlocks IDE. It is a Windows application program and is the user interface of the toolset.

 

CodeBlocks project has its own website and help file: http://codeblocks.org, and in particular: http://codeblocks.org/docs/main_codeblocks_en.html. This chapter goes through some of the common features useful to ImageCraft’s users. CodeBlocks is very powerful and flexible, and you should at least browse through the CodeBlocks document to see what features are available to you.

IDE Functions:

     Group source files into projects; where each project has its own project settings.

     Project settings specify the target chip and compiler settings and options.

     Optionally, group multiple related projects into a workspace.

     Built-in editors with syntax highlighting, code folding and other advanced editing features.

     Built-in symbol browser; allowing the users to locate declarations, definitions, and other aspects of a symbol.

     Integrated debugger and flash program downloader.

     Built-in project build manager automatically determines file dependencies.

     Invoke the C/C++ compiler to “build” the project.

“Views” and Perspectives

The CodeBlocks window contains multiple subwindows, which you can enable or disable individually. You can save a particular set of subwindows’ positions and sizes as a “perspective”. Two predefined perspectives are Default (3 subwindows, as shown below), and Minimal, with just the editor window visible.

 

View->Perspectives… allows you to change perspective view.

 

image

 

 

In the Default perspective, the Management Panel is on the left, the editor window is at upper right, and the Log Windows are at bottom right. All of the panels are multi-tabbed. You can change the default perspective by invoking View->Perspectives->Save Current and then select “Default” as the name.

Visual Components of the IDE

The Title Bar contains the name of the active file being edited, the name of the project, and the compiler license status.

 

The Management Panel contains:

     The Projects tab, where the workspace and projects and their files are shown in a tree-like display, and

     The Symbols tab, where you can browse the symbols of the workspace using different filters.

 

A workspace has one or more projects. At least one project is always active, which is indicated by its name being in bold in the project window.

 

Each project may have one or more targets. The active target is displayed at the top in a dropdown box, as shown above. The workspace and its projects are described in detail later.

 

The Editor is for editing files. Each opened file is a tab in this window. You also use the editor window to set breakpoints and perform source level stepping in the built-in JDB debugger. Editors are described in detail later. The file with the focus is called the active file.

 

The Log Window has the following tabs:

 

     Code::Blocks displays messages from the CodeBlocks program.

     Search results displays lines that match search criteria. When you double click on a result line, the editor opens the file if needed, and brings the focus to that line.

     Build log displays the all the messages from doing a project build. The detail level of the logging is controlled by the Settings->Compiler…->Other settings tab (may need to click on right arrow on the tab selection bar to see). See below.

     Build messages displays compiler messages. If you double click on any displayed warning or error message, the editor opens the file (if needed) and brings the focus to that line.

     Debugger displays messages from the debugger. Level of logging is controlled by Settings->Debugger…->(Full) Debug Log checkbox.

 

Selecting types of logging displayed in the Build Log window

image

 

The Miscellaneous Properties bar at the bottom shows various properties related to the active file. The rightmost box displays the ImageCraft variant of the CodeBlocks build, which is ARMCTX for JumpStart C++ for Cortex:

 

image

 

Toolbar Management

View->Toolbars… lets you add or remove toolbar icons for optional plugins such as Doxy Blocks (see below). You will need to save the view perspective or you will have to be redo the actions again when the IDE is restarted.

 

View->Toolbars... also lets you change the layout of the toolbar icons.

 

image


Workspace, Projects, and Targets

Menu and Popup Shortcuts

Most of the Project menu actions (some of which are described below) can also be invoked by right-clicking on the project name in the Management->Projects panel.

 

Most of the actions applicable to a project file can either be invoked by right-clicking on the file name in the project file list in the Management->Projects panel, or by right-clicking on the editor file tab if the file is open in the editor.

Project

A project is a collection of source files that, when compiled and linked (“built”), creates a program firmware image that you can download to the target MCU[4]. Associated with the project are its Build Options, and Debug/Download Options.

Workspace

A workspace is a collection of projects. A workspace file has the .workspace extension. When you open or create a project, it is added to the current workspace. If there is no opened workspace, a default one is created. All workspace-related actions are under the File menu item. The active project’s name is in bold.

 

You can save and open workspace files. There is no “New Workspace” command, as one is always created if needed.

Project Files

A project file has the .cbp extension. ImageCraft-specific information is stored in a file with a .prj extension.

 

Files belonging to a project are visually represented in a tree structure under the project name in the Management->Projects panel. Any source file in the project file list is compiled as part of the build process. Non-source files only serve documentation purposes.

image

 

You can modify how the project tree is displayed via Project->Project tree->...

 

image

Source Files

A source file is a file with .c (C source), .cpp (C++ source), .h (header file), or .s (assembly file) extension. For a C or C++ project, per language requirements, there must be a function named main() in one of the source files.

 

NOTE: if you name a file with a .S (upper case) extension, while Windows treats it the same as a file with .s (lower case) extension, the compiler driver will feed a .S file first through the C preprocessor, before calling the assembler. This allows you to use C preprocessor directives such as #include, #ifdef etc. in an assembly file.

 

When you create a new file using File->New..., CodeBlocks will ask whether you want to add the file to the current project.

 

To add an existing file to a project, invoke Project->Add files… or Project->Add files recursively....

 

To remove file(s) from a project, invoke Project->Remove files….

Targets

A project can have one or more targets; for example, a “debug” target where compiler optimizations are disabled, and a “release” target where optimizations are enabled.

 

Each target of a project may “use” all the source files of the project, or it may only use a subset. To minimize confusion, it is recommended that all source files except the Startup.s startup file (see later section) should be used for all targets.

 

To see which target a particular source file belongs to, right-click on the file name in the project file list, or right-click on the editor file tab if the file is open, and bring up Properties, then switch to the Build tab:

 

image

 

To see a list of all the files in a target, invoke Project->Properties…->Build targets tab and the resulting list of the files belonging to a target will show checkmarks next to the names on the lower right.

 

image

Active Target

You can change the active target of the current project by changing the selection in the dropdown box on the toolbar:

 

image

 

 


Debugging, Downloading, and Semihosting

JumpStart C++ for Cortex includes the JumpStart Debugger, an integrated visual debugger (to fully enable all the debugger features, a separate license must be purchased for it). The JumpStart debugger is described here.

 

You can also download a project output image directly from within the IDE through the supported debug pods. Options controlling the debugger and downloader behaviors are specified in the Build Options.

 

A nice bonus feature with the debugger is that with the supported debug pods, you can direct the output of printf calls in your program to an ADT (Advanced Debug Toolbar) windows using a feature called semihosting. This eliminates the need to set up a separate COM port or other output device for diagnostic output for debug purposes.