CLion 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.
Use Cling to interpret code
You can call Cling-related actions fromon the main menu or via (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.
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, CLion uses the project root.
If there is no project, the home directory is used.
Upon any of the Cling actions, CLion 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 CLion 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.