Cling
Last modified: 11 January 2023AppCode integrates with Cling, an interactive C++ interpreter built on top of Clang and LLVM. Cling allows you to run code without building the project, which can be especially useful for prototyping and learning C++. See the short Cling basics video.
Install Cling
Download the Cling executable for your OS or install it using the following brew command:
brew install cling
.In AppCode, go to Preferences | Languages & Frameworks | C/C++ | Cling.
If Cling is presented in the system
PATH
, AppCode will detect it automatically. Otherwise, provide the path in the field.
Use Cling to interpret code
You can call Cling-related actions from Tools | Cling on the main menu or via Help | Find Action (Ctrl+Shift+A).
To send a line or selection to the Cling session, click the bulb icon (or press Alt+Enter) on the desired piece of code:
Another option is to type code directly in the Cling terminal.
tip
Cling sessions start up with the flags collected for the currently opened file. This applies to both language standards and include paths.
Working directory for a Cling session
If there is a file currently opened in the editor, its directory is used as a working directory for Cling. Related include paths from this file work as well when sent to the same session.
Otherwise, AppCode uses the project root.
If there is no project, the home directory is used.
Cling terminal
Upon any of the Cling actions, AppCode opens the dedicated terminal window.
You can type code in this window and also load the current file or reset/close the session using the toolbar buttons.

Current issues and limitations
Adding extra arguments to the Cling executable from within AppCode is not available.
The Cling session is started within the project directory or within the home directory (if no project is currently open). The relative paths might not be handled correctly when sending a current line to Cling from a file that is not in the project root.
Thanks for your feedback!