Quantcast
Channel: CLion : A Cross-Platform IDE for C and C++ | The JetBrains Blog
Viewing all 680 articles
Browse latest View live

Get Typing Superpowers

$
0
0

CLion does its best to help you develop at the speed of thought. Code generation takes care of the repetitive tasks; code completion saves your time typing, while code navigation lets you move around the code instantly. Talking about quicker code writing, code generation (for getters/setters, constructors/destructors), generate definitions, implement and override functions and create from usage can make you significantly more productive.

The latest CLion EAP adds a new member to the family: Complete Statement.

Complete Statement helps you create syntactically correct code constructs by inserting the necessary syntax elements and getting you in position to start typing the next statement. CLion will insert parentheses, braces, semicolons, quotes, etc. for you as necessary so you avoid moving the caret manually.

To use Complete Statement, press Ctrl+Shift+Enter on Linux/Windows, or ⇧⌘⏎ on OS X.

Let’s take a closer look at some scenarios that now can be sped up. Are you ready for gifs? :)

Let’s start from the very beginning: creating a new namespace. Type the keyword (with the help of completion) and the name, and use Complete Statement to add the braces automatically:
complete_statement_namespace

Now that we have a namespace, let’s declare classes, structures, enums or enum classes. Again, there is no need to type ‘{ … };’ – Complete Statement will insert them for you:
complete_statement_class

Let’s move forward and declare some function and ask CLion to create a definition (Alt+Enter):
generate_definition_function

Now that we have a definition stub, we can fill it with some code. If you use Complete Statement, control statements like if, if ... else, for, while, do, switch will be completed with the missing braces, as will usual statements. The correct #include directive can be added with a quick-fix (Alt+Enter):
complete_statement_if_bracess

Notice how correct formatting is applied to the resulting code when Complete Statement is used.

While iterating, live templates can be handy to generate code:
generation_live_templates

However, if you still decide to type it by hand, to introduce some changes to this universal loop template, Complete Statement will again add all the necessary parentheses and braces and position the caret inside the loop, so that you can immediately start implementing the body.

What if there is more than one place to position the caret? Let’s check one more trick for getting a for loop quicker: press the Complete Statement shortcut several times and let the caret “travel” across the for loop so that you can fill the proper part:
complete_statement_travel_for

If you need to get a function definition, don’t use the Complete Statement after you’ve written the function signature, since it will only add “;” at the end of the line. Complete Statement can’t guess it and so doesn’t add braces by default. Use generate definitions or ‘create from usage’, or a simple completion to get braces automatically and the caret positioned inside the function body, so that you can start implementing it immediately:
completion_generation

That’s it! Doesn’t it look handy?! Try it out for yourself and see how much faster your typing can get with CLion’s help.

Since Complete Statement functionality is rather new, there may be bugs (stable version is planned for CLion 2016.2). Please do share invalid cases with us so that we can fix them before the release. Check it right now. Thanks!

Cheers,
The CLion Team


Webinar Recording: Design Patterns and Modern C++

$
0
0

The recording of our May 24th webinar, Design Patterns and Modern C++, is now available on JetBrainsTV YouTube channel.

In this webinar, Dmitri Nesteruk shows how the classical Design Patterns can be applied to Modern C++. He is covering both their canonical implementations as well as possible improvements.

Demo project is available on GitHub. And if you have any suggestions or improvements, your pull requests are welcome!

The video includes the time stamps following the agenda announced:
00:40 – The Adapter pattern.
10:53 – The Builder pattern.
44:16 – The Maybe Monad.

Below are some questions from our webinar answered by Dmitri.

Adapter pattern

Q: Why use Boost? Couldn’t std::tolower and std:strtok be used instead?
A: The situation with the C++ Standard Library is much worse than with equivalent standard libraries from .NET and Java. Boost is a treasure trove of useful C++ libraries, so why not use them?

Regarding std::tolower/strtok, those APIs are awful. They can be massaged to work on a std::string, but their use is pure misery, both from discoverability as well as code readability standpoints. I’m not saying Boost is that great either, but it’s much better than C-level APIs.

Q: Why the extra vector construction? Why not just return parts?
A: Because a vector<string> is not implicitly convertible to a vector<String>. And, furthermore, you cannot supply a vector<String> to boost::split(), either.

Builder pattern

Q: How do you consider adding member vs function? It’s often recommended to make a function instead of a member if you don’t need direct access to the class.
A: The advantage of a member function is discoverability. Member functions show up in code completion when invoked on a type they relate to. Global functions are not easily discoverable.

Q: Why do you make HtmlElement a struct and not a class?
A: Stylistic choice. Structs and classes are identical in C++, so I go for structs because they are more visible by default, so I can avoid messing about with visibility while doing the demos.

Q: Would it not be a good idea to implement a move constructor for p using perfect forwarding, to avoid potential copying?
A: Indeed it would, as it would in many other cases. I have omitted these concerns for the sake of brevity.

Q: Would the htlmBuilder work also with ‘auto’?
A: The part that uses operator HtmlElement would not work with auto, as the type would be inferred to be HtmlBuilder.

Other

Q: Using friends is bad practice. It breakes OCP totally. Why do you abuse it so much?
A: I agree to some extent, though I would argue that, if you are making a dedicated builder (or a set of builders) as the only way to initialize a complicated class, then it is acceptable.

Q: What is the performance trade-off of using lambdas instead of _ifs_, if there is one at all?
A: You obviously take a hit in terms of performance for using lambdas, though how much of a hit depends on how well your compiler is able to optimize these. The performance hit is compensated by the improvement in overall readability though, to be honest, C++ only does a passable job in letting us implement the monad.

Q: What’s the difference between “: person(person)” and “: person {person}”?
A: One approach is ‘legacy’ whereas the other is using uniform initialization. They are virtually identical and typically you can customize the IDE to generate one or the other. I try to use the latter as it is more fancy.

About the Presenter:

Dmitri NesterukDmitri Nesteruk is a developer, speaker, podcaster and technical evangelist. His interests lie in software development and integration practices in the areas of computation, quantitative finance and algorithmic trading. His technological interests include C#, F# and C++ programming as well high-performance computing using technologies such as CUDA. He has been a C# MVP since 2009.

Thanks to all the attendees for the questions! If you still have some, please, contact Dmitri or our team.

Learn more about C++ tools from JetBrains on our site.

Cheers,
The CLion Team

CLion 2016.2 EAP, build 162.426

$
0
0

Hi,

Last week we started CLion 2016.2 Early Access Program with Doxygen, Complete Statement and other tasty features. Today we are ready to share another build with you – 162.426.5. Download it from here, or get a patch-update in case you are using previous EAP build.

Alphabetical sorting in Structure View

Many of you asked us about alphabetical sorting in Structure View and finally here it is! To open structure view for a file you are currently in just press Alt+7 on Linux/Windows, ⌘7 on OS X. By default, entities there are grouped by:

  • namespaces
  • structures
  • classes
  • constructors/destructors
  • functions
  • typedefs
  • global variables
  • #define directives

The order corresponds to the order in the original file. In case you select Alphabetical sorting, elements in each of the group will be sorted, that makes sense for a long files with lots of entities in it.
No sorting:
structure_view_no_sort
With sorting:
structure_view_sort

Inspection tool window redesign

CLion runs code analysis on the fly and reports potential problems right in the editor. However, you can also run code analysis on the whole project or any selected scope manually (use Code | Inspect Code…). You can also run only one inspection you are especially interested in via Run inspection by name action. The results are presented in a separate window, redesigned in this build to become more readable and thus useful.
For example, now CLion shows code preview immediately when you select any result from the list.
Before:
old_unreachable
Now:
new_unreachable

Besides, when an inspection group is selected, you can now not only see the description, but also disable the inspection in-place.
Before:
old_inspection
Now:
new_inspection

VCS

In addition to the VCS changes introduced in the first EAP, this build also includes:

  • Support for ‘Apply somehow’ interactive mode for patch applying.
  • Git/Hg log shows commit details for several selected commits.

That’s it! Get a new build, try it right now and let us know what you think. Full release notes are available by the link.

Your CLion Team
JetBrains
The Drive to Develop

C++ Annotated: March – May 2016

$
0
0

Today we are happy to share our next compilation of C++ news with you.

Subscribe to the regular C++ Annotated and be the first to get the next edition!

C++ Annotated: March – May

In this edition:

  • Conferences
  • News & Stories
  • Webinars
  • Releases

Conferences

ACCU 2016

accu In April, ACCU came back to Bristol, UK, as usual. The premier UK developer conference this time brought together more than 400 attendees and over 60 speakers. Four playlists with video recordings, one for each day, are already available on YouTube. Lots of interesting topics were covered this year, for example Greg Law’s talk about profound and thus less known GDB features, Diego Rodriguez-Losada’s talk about C/C++ and Python working together, a talk from our developer advocate Dmitri Nesteruk about Design Patterns in Modern C++, and many more.

Besides, ACCU 2016 Chair, Russel Winder, gave JetBrains an interview where he talked about things that make ACCU unique, as well as his experience with Rust, D and Go languages and their future in comparison to C++.

C++Now 2016

cppnow Across the pond, C++Now 2016 was held in Aspen, Colorado, in early May. Attendees could find a lot of well-known names from the C++ community joining the event, like Sean Parent from Adobe with a keynote talk about Better code, Jon Kalb with his famous O’Reilly report about C++ landscape overview, Timur Doumler, a JUCE developer from ROLI, Marshall Clow, Barbara Geller, David Sankel, and many others.

Check out the best session winners and learn about C++Now 2017 dates in the blog post.

Italian C++ Conference 2016

Another C++ event was held in Italy in May. More than 100 people attended the very first Italian C++ conference in Milan. You can find the report about the event here. In particular, we want to draw your attention to two of James McNellis’ talks, Adventures in a Legacy Codebase and An Introduction to C++ Coroutines.

News & Stories

C++17 standard news

cpp March brought several reports about the C++ meeting in Jacksonville, Florida. Herb Sutter posted a long and detailed one in his blog. Despite many expectations and hopes in the C++ community, modules and concepts won’t come to C++17. However, for now they will both stay in their own technical specification. Coroutines are targeted for another TS as well. On the good side, Herb lists the features that are making their way to the upcoming C++ standard, like Parallel STL and several more TS that were merged into the final C++17 edition, and several features coming directly to the new standard like fallthrough, nodiscard and maybe_unused attributes and more. The future of C++ is presented in Herb’s blog post in a simple timeline, followed by an interesting open-ended question: Will C++ stay on the 3-year cycle or move to a 2-year cycle?

C++11 smart pointers

C++ developers (both students and professionals) can find this blog post useful, as it uncovers 10 dangerous pitfalls when working with C++11 smart pointers. It tells you where it’s better to use shared_ptr, unique_ptr and auto_ptr; how to avoid double memory allocation by using make_shared; and lays out the rules for working with the raw pointers.

lambdas and std::function

lambda C++11 lambdas are already widely used. The idea is pretty simple. The easiest (though probably useless) example is “[](){}();”. But do we know them well enough to answer even basic questions? What is the lambda’s type and why is it not std::function? How long do the variables captured by lambda stay alive? What is the size of a lambda? If you feel like testing your knowledge of lambdas, head straight to this blog post.

Conan

conan In the previous edition we already mentioned Conan, a C/C++ package manager. This time we’d like to share more information about it. First up is a CppCast episode with Diego Rodriguez-Losada, known as a biicode startup co-founder and currently Conan committer. Watch the episode to learn the Conan story first-hand.

There is also a great post in Conan’s blog for those interested in setting up a full environment for C/C++ development based on Clang as the compiler, CMake as the build system, CLion as the IDE, and Conan as the package manager. Check the steps and follow advices for an easy set-up.

Compiler Bugs Found When Porting Chromium to VC++ 2015

64_read Bruce Dawson from Google posted some great material on the bugs found while porting a big Chromium project from VC++2013 to VC++ 2015. The incredible work includes attempts to build some smaller samples to reproduce the problems, as well as some deeper analysis of the situations. Read the post to know about a problem with zeroing a five-byte array, a crash that would happen only under Profile Guided Optimization, an incorrect 64-bit structure read, and more.

Telemetry function calls in VS 2015

telemetry Recently the C++ community has been discussing the telemetry call in every binary compiled in VS2015. The discussion was huge as conspiracy theories are always popular, even though the logs written in that case were quite limited and have to be switched on manually (so not working by default).

However, the discussion on reddit got an official comment. Steve Carroll from the Visual C++ team has promised that the corresponding calls will be removed in Update 3. He explained that the main intent was to build a framework that would help investigate performance problems and improve the quality of the optimizer.

C++ I/O Benchmark

compilers Cristian Adam posted in his blog nice and solid benchmark for C++ cross-platform calls for Input/Output on Windows 10, Kubuntu 15.10 and Raspberry PI2, testing on a huge set of compilers: GCC, Clang, Visual C++ (2013/15), MinGW GCC, Cygwin GCC and Cygwin Clang. During the test he was reading one file in chunks of 1 MB and writing it to another file. The tested API calls were: C file API (fopen, fread, fwrite), C++ API (std::ifstream, std::ofstream) and POSIX API (open, read, write). And the winner’s crown went to… POSIX. See the full blog post for some interesting numbers.

CppCast

cppcast
CppCast continues gathering famous C++ community members. Jens Weller talked about the Meeting C++ platform that brings the conference, site and recruiting platform to the C++ world. Get the whole story first-hand. An interview with the author of the renowned blog Simplify C++, Arne Mertz, was recorded for CppCast in March. Find the discussion of the latest standard and more topics in there. April brought an interesting discussion with Ankit Asthana about cross-platform development, Visual Studio Code and Visual Studio for Linux. Elena Sagalaeva (known by the Russian-speaking community for her famous blog on C++ in Russian) attended the podcast in April as well, talking about distributed computing and how the latest C++ standards are useful there.

Webinars

Design Patterns and Modern C++

The recording of our May 24th webinar, Design Patterns and Modern C++, is now available on JetBrainsTV YouTube channel. In this webinar Dmitri Nesteruk shows how the classical design patterns that arose in 1994 from the infamous Gang of Four book continue to be as useful to this day. We are discussing the adapter pattern, the builder pattern and the maybe monad. Several questions from the webinar answered by Dmitri can be found in the corresponding blog post.

Releases

GCC 6.1

gcc-logo The new major release of GCC compiler was announced and brought lots of goodies. First of all, C++14 is set as a default. Besides, many features from the upcoming C++17 were added to the compiler (for both language and standard library), and even Concepts, that were postponed by the committee to another TS, are available in GCC 6.1 via -fconcepts.

Checking the list of the General Optimizer Improvements in the release notes, you may notice an interesting point that C++ developers definitely should heed: “Value range propagation now assumes that the this pointer of C++ member functions is non-null”. You may want to check whether your code base is affected by the change, just as it happened to Qt5, Chromium and KDevelop. Anyway, GCC authors suggest a temporary workaround: -fno-delete-null-pointer-checks.

Clang 3.8

libclang A lot of goodies were delivered with the Clang 3.8 release, including OpenMP 3.1 (and several elements of the OpenMP 4.0/4.5), experimental support for end-to-end CUDA compilation, static analyzer improvements, and more. You can also track the progress of the new features through the Clang 3.9 (in progress) release notes.

ReSharper C++ 2016.1

R++_400x400_Twitter_logo_white April brought the release of ReSharper C++, a Visual Studio extension for C++ developers. In addition to Google Test support, Boost.Test is now added, including a built-in test runner. This version allows you to mark your code with TODO, BUG, FIXME or any other pattern you may prefer (configurable in settings), and navigate through the marks easily using a special Todo Explorer.

The release also brought a long list of new quick-fixes and context actions that help improve the code, by suggesting various fixes. One example is when ReSharper C++ detects an uninitialized constructor parameter, it offers a context action to create and initialize the corresponding field. Find more details about the new version in this blog post.

CLion 2016.1

CLion_400x400_Twitter_logo_white CLion, a cross-platform IDE for C and C++ developers, got an important update. Release 2016.1 finally brought variadic templates support and auto-import for STL symbols. Quick Documentation pop-up was enhanced with the hyperlinks to the related symbols. During debugging users are now allowed to attach to the process running on a local machine but not started from the IDE – all the benefits of the built-in debugger UI are still there.

To speed up the indexing time, CLion 2016.1 lets you mark directories as excluded (several more option like libraries or sources are also available).
Overgrowing just C and C++ development, CLion turns to the multi-languages projects bringing Python and Swift support on board. Feel free to check the details in the CLion’s blog.

Finally, CLion started a new Early Access Program for version 2016.2. This build addresses Doxygen support, Complete Statement and VCS changes, CMake rename refactoring for users symbols and more.

Qt Creator 4

qt Qt came out with big news in May and released Qt Creator 4.0.0. It includes CMake workflow changes (like automatic triggering when necessary, UI to change the CMake configuration for a build directory and more), automatic use for the Clang code model, Clang static analyzer integration available under open source, fixes for the latest LLDB version and several more improvements.

Visual Studio 2015 Update 2

vs_cpp Microsoft has given us a lot of exciting news in these months. Update 2 comes with many interesting changes for C++ developers. C++ compiler got many bug fixes, with the most notable changes including support for Variable Templates and constexpr improvements. At the same time, many C++17 features have made their way to C++ standard library as well.

However, the biggest improvement is probably for those who develop for Linux, as the new extension makes possible C++ development in Visual Studio for Linux. You can now create projects and manage connections to the Linux machine right from the VS. Upon connecting, VS will copy your sources to the remote Linux machine and will invoke GCC to build the sources with the options from the project properties. Then you can debug your code remotely.

Looking into the future of Visual C++ compiler, read this blog post about upcoming changes in Visual C++ code optimizer. Find out the reasons behind the new optimizer, and see several samples of implemented optimizations.

That’s it! Let us know in the comments if you like current edition.

Cheers,
The C++ Team

CLion 2016.2 EAP, build 162.646

$
0
0

Hi everyone,

Another week brings another EAP build, that includes new code style settings and several important bug fixes for you to try.

Code Style for C and C++

This build adds a few options to the C/C++ Code Style settings. Wrapping and Braces group got a new After function return type options, that allow you to configure whether to wrap the lines after function return type in a scope of a class and in global and namespace scopes. By default there is ‘Wrap if long’ value set for both of them:
wrap_return

Several setting for Lambda capture list were added in Wrapping and Braces as well:
lambda_settings

There are also new options to configure wrapping for ‘<<' and '>>’ operators. And in Spaces | Within group you can now configure if you’d like to get a space within empty code braces.

Besides, this EAP build provides you with two new coding schemes to follow – LLVM and LLDB. To apply setting from any of these scheme, select Set from… | Predefined Style and select the scheme you prefer.

Other fixes

Several important bugs addressed in this build are:

  • In case you only changed a case of some letter while renaming a file, this file disappeared from the Changes view on Save (IDEA-94470).
  • In the case described above committing this change to Git repository also failed, and it happened for both file and folder names changes (IDEA-53175).
  • It was not possible to use Windows-key (Super-key) as a modifier key in keymap on Linux and Windows (CPP-4246, CPP-5768, IDEA-144702)

Full list of release notes is available by the link.

Download the build, or get a patch-update in case you are using previous EAP build.

Your CLion Team
JetBrains
The Drive to Develop

CppCast welcomes CLion: a year in review

$
0
0

CppCast, a famous podcast for C++ developers hosted by Rob Irving and Jason Turner, welcomes back Anastasia Kazakova, CLion Product Marketing Manager. Last time we met a year ago, before CLion 1.0 was launched, and talked about CLion’s goals, hopes and expectations. Now we meet again to overview CLion’s first year. Some topics discussed in this episode include:

  • Main changes and events for CLion and the C++ team in JetBrains over this year.
  • General trends in how CLion’s features are used.
  • Discussion of CLion’s user base.
  • Any option to get CLion licenses for free?
  • What’s next on the roadmap?
  • CLion as an IDE not only for C and C++. What are other languages and options are there?
  • Some technical details on how CLion works with CMake and future plans for other build systems.
  • CLion’s C++ parser discussion, along with clang as an option.

Sounds interesting? Listen to the episode here.

Anastasia KazakovaA C/C++ fan since university, Anastasia has been creating real-time *nix-based systems and pushing them to production for 8 years. She has a passion for networking algorithms (especially congestion problems and network management protocols) and embedded programming, and believes in good tooling. Now she is a part of the JetBrains team working as a Product Marketing Manager for CLion.

CLion 2016.1.3 bug-fix update

$
0
0

Hey there,

We are publishing CLion 2016.1.3 bug-fix update (build 145.1617) today.
A few notable fixes:

  • CPP-6013 Wrong “Binary operator ‘<<‘ can’t be applied” error message.
  • CPP-6254 Output for CLion IDE sometimes cuts off when executing a program.
  • IDEA-156750 Slow IDE launch on cellular network.

We are also bringing a new feature in this update:

Alphabetical sorting and type grouping in the Structure View

To open structure view for a file just press Alt+7 on Linux/Windows, ⌘7 on OS X. By default the order corresponds to the order in the original file. With grouping by type elements are shown in the following groups: namespaces, structures and classes, constructors/destructors, functions, fields, etc.

No sorting:
no_sorting

Grouping by type:
type_sorting

Grouping by type and alphabetical sorting:
type_alpha_sorting

Full release notes can be found here.

The update is available for download from the site or as a patch via Check for Updates in the IDE.

Your CLion Team
JetBrains
The Drive to Develop

CLion 2016.2 EAP: debugger bug fixes and performance enhancements

$
0
0

Hi all,

This week brings a very important CLion 2016.2 EAP (build 162.844.13), as it contains big changes introduced inside CLion’s debugger. We’ve already made a couple of attempts to fix ‘command time out’ and other problems there, but issues still exist and are constantly reported by our users. We’d like to thank you for all the reports and logs you’ve sent. Your collaboration made it finally possible to introduce major changes in GDB and LLDB drivers.

Here’s what to expect from this build.

Debugger

Command timeout

Sometimes an error would happen while collecting frames on breakpoint/interrupt or when the debugger was being launched. The debugging session would hang for some time and then a command timeout was reported to the user. Now a proper error message is reported to the console and in a notification balloon, so the ‘command timeout’ error shouldn’t bother you anymore.

Debugger correctness

We overhauled debugger drivers, making it possible to fix many bugs with stepping and variables views, for example:

  • Value in “Variables” window wasn’t updated after the variable was set (CPP-5933).
  • Debugger failed to show frame variables when stepping into a function if const STL container was in outer frame (CPP-6150).
  • GDB didn’t exit correctly when program waited on cin (CPP-5615).
  • LLDB didn’t stop on breakpoints on case-insensitive file system if there were differences in file names/paths casing (CPP-6598).

GDB and LLDB versions updated

We’ve also updated the bundled LLDB version (OS X only) to 3.8 and the GDB version to 7.11. Along with supported GDB version update, the maximum supported version of MinGW-w64 was updated to 5.3 and Cygwin to 2.5.

Performance improvements

After all changes in both drivers, we ran performance tests to evaluate how they affected debugging startup/shutdown, stepping with various data views and expanding big data structures. The numbers are really promising (the picture shows the correlation between new and old data):

debugger_tests

Besides, there were a few tests which finished with the TIMEOUT previously, while now they take some reasonable time to complete, like for example displaying strings or STL collections.

Other improvements

CMake and Safe delete

Since the very first releases, when you add a new file, CLion has suggested updating the CMake targets with the newly created file. However, this automatic update was not possible in case of file deletion. Now it is!

If you delete a file listed as an argument in certain CMake commands, CLion will search for file usages in CMakeLists.txt files, warn you about an unsafe operation, and update the usages automatically. These CMake commands include:

  • add_executable
  • add_library
  • set
  • add_custom_target_command
  • fltk_wrap_ui
  • qt_wrap_cpp
  • qt_wrap_ui
  • set_property
  • set_source_files_properties, and
  • try_compile

Note that if there are other files listed in the command arguments, CLion will simply delete the reference to the deleted file:
file_safe_delete

However, if the reference to the deleted file is the only command argument, deleting the reference (as well as the command itself) could lead to an incorrect CMake file, so this warning will be shown. You can then view the usages and decide if you’d like to proceed with deleting:
last_file_safe_delete

It works not only for C and C++ files, but for any file type (list resources for example, or other CMake scripts). Directories are not currently supported.

Live templates

We’ve updated Boost-related live templates for CMake files and now there are two – boost and boost_with_libs. The latter is for linking your target with the Boost libraries. You only need to fill the components list and the target name:
boost_libs

Generate definitions

When we first introduced the Generate definition action some users were confused by its behaviour. That’s why we’ve collected all the feedback and considered the cases carefully once again. In general, there are several popular behaviour templates:

  • declarations are located in header files, definitions are in cpp-files,
  • class/struct is located in header file only,
  • class/struct is located in cpp-file only,

as well as any other custom case users might be interested in.

CLion now detects the case automatically, providing Generate in-place setting in the generate dialog:

  • It’s always unchecked when the action is called outside a class or a namespace.
  • When called inside a class or a namespace:
    • Unchecked if there are existing functions in the class with outside definitions.
    • Checked if there are no functions in the class or all the functions are in-place.
    • Unchecked if there are no functions in the class, the class is in a header file and there is a corresponding source file (unless it’s a template).

You can use this Generate in-place setting to control the behaviour:
generate_definition

Font ligatures

Font ligatures are officially supported by the IntelliJ-based IDEs now, and so does CLion. If you have a font that supports ligatures installed (e.g. FiraCode, Hasklig, Monoid or PragmataPro), then simply go to Preferences/Settings | Editor | Colors & Fonts | Font, choose a corresponding font there and select the Enable font ligatures option. That’s it!
ligatures_font

There are a few more nice changes:

  • IDE’s notifications are now more friendly – there appear in the rightmost bottom corner and are grouped by the subsystem.
  • If you’d like to have a nice background image in your editor, it’s now possible in CLion. Call Find Action (Shift+Ctrl+A on Linux/Windows, ⇧⌘A on OS X), type Set Background Image, select an image and configure its settings in the dialog that appears:
    sea_line_background
  • Git/Mercurial log viewer now loads in the background on every change (a commit, fetch, rebase, etc) to be always ready when you open it.

As usual, the full release notes are available here.

We encourage you to try the build and let us know about any issues, particularly those affecting the debugger. If you experienced performance problems before, please share if you see any enhancements with the current build.

Your CLion Team
JetBrains
The Drive to Develop


CLion 2016.2 EAP, build 162.917.13

$
0
0

Hi,

Fresh CLion 2016.2 EAP build (162.917.13) is now available for download. If you are using previous EAP build, you should soon get a notification in the IDE about a patch update.

Starting from this build CLion doesn’t show “Function is not implemented” warning in case of:

  • private copy-constructor: TypeName(const TypeName&),
  • private simple assignment operator: void operator=(const TypeName&).

For example, in the following code:
disallow_copy

This build also brings fixes for the following issues:

  • Splitting function into declaration and definition doesn’t take focus to the implementation and puts caret in a non-convenient position (CPP-6731).
  • “Preview Occurrences” option in Find In Path toolwindow stoles focus (IDEA-156921).
  • One line change in the file tracked by Mercurial in some situations forces to mark all content as new (IDEA-157085).

Recently we’ve added an ability to add background image in your editor. A few fixes for it were introduced in this build:

  • You can now set background image per project (IDEA-117223).
  • When opening files in new windows, these new windows now inherit background image from the editor (IDEA-157035).

Find the full release notes by the link.

Your CLion Team
JetBrains
The Drive to Develop

CLion for embedded development

$
0
0

Hi,

Are you interested in embedded development? In this guest blog post our user Ilya Motornyy shares his experience in programming for microcontrollers in CLion.

Ilya Motornyy
Ilya Motornyy
Java/JavaScript Developer at Vaadin.com
DIY Electronics and Embedded Programming Enthusiast.

Introduction

CLion is a relatively new IDE for C/C++, based on very popular IntelliJ Platform, and hopefully it inherits most of the nice features of IntelliJ IDEA like code highlighting, autocompletion, refactoring, and analysis. Although CLion in its current state is not targeted at embedded development, it’s still possible to use it for this purpose. Embedded programming here means no operating systems, clipboards or other processes.

One of the most popular microcontrollers (MCU) nowadays is a huge family of ARM Cortex-M compatible processors, based on the 16/32bit ARM kernels, but made by different companies. Many of them are quite powerful and at the same time cheap and relatively easy-to-program. Let’s try to program something for one of them with CLion.

A good target platform is NUCLEO-F303RE – a development board for STM32f303RE MCU. This is ARM Cortex M4+FPU MCU, 72MHz, 64(RAM)/512(ROM) kB of memory. Let’s use a Linux-based (Ubuntu 16.04) computer for this development.

Hardware, or how to run programs

The main difference between desktop and embedded programming is how to run or debug the program. In case of desktop, the program is just run directly or under dbg for debugging.

In case of embedded, the program (firmware) should be downloaded into the target chip, and then run (in most cases the MCU is just reset after download). This could be done through the bootloader (USB, UART, I2C, SPI, OTA etc.) or through the hardware JTAG probe. To debug firmware, JTAG probe is required as well as remote dbg support for it. It case of ST development boards (both EVAL, Discovery or NUCLEO series), there are on-board ST-link compatible JTAGs. CLion has dbg support, but unfortunately there is no support for remote dbg, and it is not possible to use CLion’s internal debugger for any embedded development yet (please vote).

Luckily, there is a company called Segger that produces its own JTAGs and a debugger on top of that. Now it’s possible to upgrade onboard ST-Link debugger to full-featured J-Link debug probe. Note that the upgrade license allows you to use this upgrade for ST evaluation boards only; production use is prohibited.

Of course, if you have Segger J-Link device, you can use it according to the license terms and just skip board upgrade. In this case, Nucleo onboard st-link jumpers must be removed, and the probe must be connected directly to MCU pins.

To perform this upgrade you need a Windows computer (VirtualBox or VMWare might help) and Segger upgrade utility. The same utility can downgrade the board back to ST-Link.

Other options

If you use another ST ARM MCU or board, you can use this article as a general HowTo, and flash your device using USB DFU mode and dfu-util, or using UART bootloader. See the application note AN2606 for details about STM32 MCUs bootloaders.

If nothing works, then there is openOCD, which can be used to download firmware (and debug, when CLIon introduces remote dbg support).

Software

CLion

Just download it from JetBrains site and install by following the instructions. CLion is a paid product, but it can be used for 30 days for free under trial license. You may be able to apply for a discounted or complimentary license.

CMake

All CLion projects are based on CMake build model. CMake is shipped with CLion and any Linux distribution contains it as well. You can use whichever you want.

Segger

Segger software can be downloaded from their site. J-Link Debugger is a must, all other pieces of software are up to you. Choose the appropriate version (32 bit or 64 bit), and packaging for your version of Linux (DEB for all Debian derivatives, including Ubuntu).

GNU GCC for ARM (gcc-arm-none-eabi)

The absolutely mandatory part of the software is a compiler. We will use gnu-gcc for embedded ARM processors. Thanks to launchpad.net guys, we can just install or download pre-build gcc binaries.

STM32CubeMX

The last piece of required software is STM32CubeMX, a universal GUI tool for configuring MCU peripherals and for code generation. Download the installer from st.com and run it.

Firmware library

Finally, run the utility and install a fresh utility for the target MCU. Open Help->Install New Libraries->STM32CubeF3->check latest revision->Install Now. The firmware library is quite large so the process will take some time.

New Project

STM32CubeMX

Now everything is ready to create your very first project. Run Cube software, click New Project, then select Board Selector tab, and choose the target platform Nucleo64 NUCLEO-F303RE.

image11

Now we can see the default MCU configuration for the board. Pin PA5, connected to onboard LED, is already set to GPIO_Output mode, and we can use it for classic “blink” example.

image15

Now it’s time to generate project code. Press Project->Generate Code. In the opened dialog, configure the target folder and set the target Toolchain/IDE to SW4STM32, since CLion is not supported by Cube software.

After pressing OK, Cube software generates the full set of sources, including libraries, linker script and startup code for the given MCU type.

image16

CLion Project & Settings

Now that the codebase is generated in the target folder, let’s create a CLion project on top of that. A good start is to choose Import Project from Sources (the same can also be done from the home screen or from the File menu). The IDE generates a CMakeLists.txt file for us, but for this project you should create a different one:

project(f3_blink C ASM)
cmake_minimum_required(VERSION 3.5.0)

add_definitions(-DSTM32F303xE)

file(GLOB_RECURSE USER_SOURCES "Src/*.c")
file(GLOB_RECURSE HAL_SOURCES "Drivers/STM32F3xx_HAL_Driver/Src/*.c")

add_library(CMSIS
        Drivers/CMSIS/Device/ST/STM32F3xx/Source/Templates/system_stm32f3xx.c
        Drivers/CMSIS/Device/ST/STM32F3xx/Source/Templates/gcc/startup_stm32f303xe.s)

include_directories(Inc)
include_directories(Drivers/STM32F3xx_HAL_Driver/Inc)
include_directories(Drivers/CMSIS/Include)
include_directories(Drivers/CMSIS/Device/ST/STM32F3xx/Include)

add_executable(${PROJECT_NAME}.elf ${USER_SOURCES} ${HAL_SOURCES} ${LINKER_SCRIPT})

target_link_libraries(${PROJECT_NAME}.elf CMSIS)

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Map=${PROJECT_SOURCE_DIR}/build/${PROJECT_NAME}.map")
set(HEX_FILE ${PROJECT_SOURCE_DIR}/build/${PROJECT_NAME}.hex)
set(BIN_FILE ${PROJECT_SOURCE_DIR}/build/${PROJECT_NAME}.bin)
add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
        COMMAND ${CMAKE_OBJCOPY} -Oihex $ ${HEX_FILE}
        COMMAND ${CMAKE_OBJCOPY} -Obinary $ ${BIN_FILE}
        COMMENT "Building ${HEX_FILE} \nBuilding ${BIN_FILE}")

There are some adjustments for the compiler and .bin and .hex files generation.

The next step is to write the cross-compiler toolchain file. For STM32f303xE this file looks like this:

INCLUDE(CMakeForceCompiler)

SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_SYSTEM_VERSION 1)

# specify the cross compiler
CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU)
CMAKE_FORCE_CXX_COMPILER(arm-none-eabi-g++ GNU)

SET(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/STM32F303RETx_FLASH.ld)
#SET(COMMON_FLAGS "-mcpu=cortex-m4 -mthumb -mthumb-interwork -mfloat-abi=soft -ffunction-sections -fdata-sections -g -fno-common -fmessage-length=0")
SET(COMMON_FLAGS "-mcpu=cortex-m4 -mthumb -mthumb-interwork -mfloat-abi=hard -mfpu=fpv4-sp-d16 -ffunction-sections -fdata-sections -g -fno-common -fmessage-length=0")
SET(CMAKE_CXX_FLAGS "${COMMON_FLAGS} -std=c++11")
SET(CMAKE_C_FLAGS "${COMMON_FLAGS} -std=gnu99")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,-gc-sections -T ${LINKER_SCRIPT}")

Before first compilation, your CLion project will need some adjustments. Go to File -> Settings and under Build, Execution, Deployment -> CMake set the following:
CMake options: -DCMAKE_TOOLCHAIN_FILE=STM32F303xE.cmake
Build output path: build

image04

Reload your CLion project (Tools -> CMake -> Reset Cache and Reload Project). Now the project is ready to be compiled in the IDE (Run -> Build). If everything is done correctly, .bin and .hex files should appear in build folder.

First run of Segger J-Link Debugger

Select Run -> Edit Configurations… and create a new Application. Enter any name and specify the following options:

  • All Targets for Target
  • Debug for Configuration
  • /opt/SEGGER/jlinkdebugger/2.14.9/JLinkDebugger for Executable
  • run.jdebug for Program arguments
  • Enter the project folder path for Working Directory
  • Check Single Instance only

Finally, click OK.

image18

Now the debugger can be started right from the IDE. Segger Debugger needs its own project to be created. To make it happy, choose File -> New -> New Project Wizard…

In the open wizard, choose the appropriate MCU, then interface configuration, then data file – i.e. our compiled .elf file in the build folder.

image17

image19

image12

When the wizard finishes, click File -> Save Project As…, choose your project folder and enter run.jdebug into the File Name field (same as in run configuration in CLion).

Wait, when we are going to code?

Exactly! Now everything is set up and ready for you to start coding. To see a real “blink” example, just add those two lines inside a while loop in the main() function.

image13

After this modification, you can just run your JLINK Debugger configuration. The project will be automatically built, and the debugger will be started on top of that. In the debugger, press F5 to download and start the firmware, then click Yes to agree with the evaluation mode, then press F5 again to run the main() function. The green LED LD2 will start blinking with 1Hz frequency.
Now you are able to use all Segger debugger features.

image14

Pro Tip

STM32CubeMX code regeneration

You can run Cube software over your project multiple times, and regenerate configuration code as many times as you need. To preserve your own changes to the sources during code generation, surround your the changes with the comments /* USER CODE BEGIN ??? */ and /* USER CODE END ??? */. Cube leaves those code blocks untouched. Of course, you can add your own .c files to the project.

Conclusion

CLion is really good IDE for C-based projects, and as you can see here, it’s possible to use it for embedded ARM MCU development. This article covers only one MCU chip and only one JTAG probe, but the manual can be easily adapted to any STM32 MCU and other vendors’ chips as well. At the moment, CLion team is working on remote GDB support.

Jon Kalb speaks about CppCon, C++17 standard and C++ community

$
0
0

Here comes another interview in our blog. This time we speak with Jon Kalb, CppCon Chair and C++ instructor.

Russel WinderJon Kalb is a freelance C++ instructor and chairs CppCon, C++Now, and the Boost Steering Committee. He has been programming in C++ for over 25 years and has written C++ for Amazon, Apple, Dow Chemical, Intuit, Lotus, Microsoft, Netscape, Sun, and Yahoo! Jon has taught C++ at the graduate school at Golden Gate University in San Francisco and is a Microsoft MVP.

Twitter: @_jonkalb

Jon: Anastasia, thank you for this opportunity to share my point of view and for what you and JetBrains are doing to support the C++ community, particularly, CppCon, C++Now, and CppCast.

Anastasia: How do you feel in general about the C++ community? You meet so many developers at CppCon and C++Now and at each meetup you are participating. What are they mostly interested in?

Jon: Obviously I wouldn’t have invested so much of my career in this community if I didn’t find value here. I’ve found that C++ developers, at least the ones that are interested enough to attend user group meetings, conferences, and the classes that I give, to be concerned about doing things right. By that I mean producing well-engineered code. Code that is clear and therefore understandable and maintainable, modular and therefore reusable, and efficient in time and space. Hacks that “get the job done,” but create maintenance problems down the line are not looked on favorably. These characteristics mean that the code that they are producing will be valuable to their organizations for years to come.

Anastasia: With your strong relationship with the C++ community lasting for so many years, you must be able to outline some major trends where the community is moving in terms of language usage, libraries and tools?

Jon: The kind of developers that speak at conference and attend standards committee meetings are leading edge and are working with cutting-edge language features sometimes even before they are standardized. But the vast majority of development teams are slow, sometimes very slow to adopt languages changes. Library adoption can happen more quickly, but I see some missed opportunities here as well.

I am seeing some improvement. I do think we are seeing that “regular” programmers are now more comfortable with templates and modern solutions. I suspect that most of this is just the result of years of exposure to templates, but some is no doubt that Modern C++ (C++11/14/17) has made template solutions a little easier to create.

Anastasia: Talking about C++17, after the C++ meeting at Jacksonville some developers were disappointed about some features not making their way to the standard, such as Modules, Concepts (and thus Ranges), Coroutines. One even called C++17 a minor update. Do you also feel we’ll get a less significant language update with C++17?

Jon: There is no doubt that it won’t be as significant as many people were expecting. I think there was a lot of over-promising and that can lead to a backlash of disappointment. It was apparent to me last year that most of the features that people were expecting were only at the Technical Specification stage.

For those that aren’t familiar with the process (which is relatively new for C++), the standards committee has the option of releasing a Technical Specification for major features before the feature is accepted in the standard. The point of this is to allow tool makers to implement and users to get experience with the feature before it is frozen into the standard. But this is only useful if the committee gives the TS time to be implemented and used, so that we can learn from it. The model needs to be: release the TS, give it time to be implemented and used in real-world production, and then revise the specification based on this experience before adding it to the standard. If the committee releases a TS one year and then puts it in the standard the next year, to me, it seems to be defeating the purpose.

Many of the features that people have been expecting are only at the TS stage and are not ready for C++17.

But I’m not disappointed. I don’t think the committee has been wasting its time. I’m very happy that committee has decided to make a rock solid C++17 and release several valuable Technical Specifications for the community to use and evaluate.

I think we as users need to change our thinking about the standard, because we need to recognize the value of the Technical Specifications. They are not (yet) part of the official standard, but are valuable tools that we as engineers can use to get work done. The specification may be “beta,” but that doesn’t mean that the code provided by tool vendors can’t be used in production code. Each team needs to evaluation on a case by case basis if a specific TS is appropriate for a specific project, just like we always evaluate the cost of accepting the dependency of a third party library.

I’ve said before (on twitter), I’d rather have a solid feature spending time in a TS then have a premature feature accepted in the standard. I think there are some features in C++11 that would have been better if they’d gone through the TS process.

Anastasia: You do CppCon, a fantastic and famous event in the C++ world, the best one probably (at least from my personal opinion). Assuming someone is going to start a conference, any advice you can give them? Maybe some tips?

Jon: On behalf of the CppCon team, thanks for your kind words. There are now at least three other very strong C++ conferences in the world: ACCU, C++Now, and Meeting C++ and that is not counting the JUCE summit for audio devs, so I don’t know if we need any more competition, but I’ll share how we think about C++Now and CppCon in case that helps anyone thinking about an event.

There is a secret ingredient and a magic ingredient. The secret ingredient, of course, is unpaid labor. If we had to pay the speakers what their time is worth for their presentations, let along for their preparation time, we couldn’t afford to do either CppCon or C++Now. The fact is that some of the best minds in our community are anxious to share what they’ve learned. I think there is a feeling that C++ is difficult and we are all in this together to figure out and share best practices. Some of these speakers are freelancers like me who are doing this to promote their businesses, but most of the speakers we have are working software engineers whose companies are supporting their efforts to promote best practices and push the envelope of C++ development.

The magic ingredient is the attendees. Many of them and most of their bosses, think they are coming for the sessions, but regular attendees know that you really come to talk to the other attendees. What I say about C++Now is that the program is the second best thing about the conference and if you want to know what the best thing is, talk to an attendee. This is also true for CppCon.

We put a lot of time and effort into freely distributing recordings of (almost) all our sessions. For CppCon we pay to have the sessions professionally recorded, edited, and posted to YouTube and Channel9. If these recordings represented the real value of the conference, we’d be putting ourselves out of business by distributing them so freely. But you don’t get the real value out of the conference by staying home watching the videos. The real value of the conference comes from the conversations that you have with your fellow attendees.

By fellow attendees I do include the speakers. One well-known speaker told me that before CppCon they attended two kinds of conferences–ones where they presented, but weren’t interested in attending any other sessions and ones where they attended sessions, but didn’t present. At CppCon, the presenters are as excited to be attending sessions and be part of the discussion as anyone else.

One tip that I might share with anyone wanting to start a conference, neither C++Now nor CppCon have a “green” room or speakers’ lounge or anywhere that speakers can “hide” from attendees. I heard from one attendee that they were delighted to see Bjarne in line to register just like everyone else. Our conferences are very democratic. My badge as a conference chair looks just like Bjarne’s badge as keynote speaker and just like the badges worn by all the registered attendees, volunteers, and exhibitors. I think this creates an environment where the speakers are approachable and discussion is encouraged. The speaker to attendee ratio is much better at C++Now because it is a smaller conference, but CppCon speakers are available, approachable, and interested in engaging with attendees.

Anastasia: CppCon 2015 was big and really interesting with great keynotes by Bjarne Stroustrup and Sean Parent, fantastic talks (my personal favourite was Eric Niebler doing magic with a calendar and ranges), many one-on-one conversations and some spontaneous off the agenda events. How was it from the organizational perspective? Any interesting story behind the scene you can share here?

Jon: I have one story to share, but mostly, you don’t want to know what happens behind the scenes. I always ask attendees how their conference is going and I’m very happy whenever I’m told that people are having a great time and haven’t seen any problems. Because I hear about every problem. If a badge is misspelled, if a session starts late due to a technical glitch, if something goes wrong at break time, I hear about it. I very much hope that attendees see a smoothly running conference, but what I see are several (small) problems that happen every day of the conference. Even after the fact when everything has been workout, I still hear about every issue. That is how it should be because that is how we learn how to avoid these problems in the future.

But I’ll share one story from last year. On the way to the conference one morning, Lloyd Moore, one of the leaders of the Northwest C++ Users Group and a CppCon volunteer, spotted a kitten on the freeway. He stopped his car—on the freeway in Seattle rush hour traffic—to rescue this kitten. So for awhile we had a kitten at registration, being looked after by the volunteer team. The kitten, given the names CppCat or Schrödinger, depending on who you asked, was adopted by the one of the employees at the Meydenbauer conference center. Here is the complete story with photos including one of Lloyd holding the kitten whose life he saved:
12001009_411125959084763_6835397513722884720_o

Anastasia: And you know I have to ask. CLion. What do you think of it? Have you tried it? Maybe even using it on a daily basis? If so, any feedback you’d like to share?

Jon: I use CLion as my default editor for C++ code, so I do use it regularly. I feel like it has a lot of features that I a haven’t tapped into yet. Unfortunately, I don’t have much feedback to give you because, since I quit my “day job” working on the Amazon search engine to pursue my dream job of onsite training (and running conferences), I’m not working on a large code base. I create very small applications to test out features or techniques or to use as in-class exercises as part of a course I’m working on. My use of CLion is just very different from your typical C++ developer that would stress it with thousands of files and millions of lines of code.

Anastasia: Last year JetBrains actually started several IDEs for C++: CLion and ReSharper C++. Bjarne Stroustrup in his keynotes talking about code analysis and C++ Core Guidelines at CppCon 2015 stated that “we need tools”. In 2015 also package managers for C++ started evolving widely with Biicode and Conan. And my question is do you think it’s really the era of tools for C++? Taking into account that the language has celebrated its 33 year birthday?

Jon: Don’t forget the build2 build system by Boris Kolpackov.

I hope this is an era of tools for C++, because there are so many opportunities. Not only for a cross-platform IDE that really understands C++, like CLion, and analysis tools like we have seen based on the Clang sanitizers and the Core Guidelines, but also a defacto standard package manager. Of these I think the package manager is the most daunting. It seems so easy because we see that other languages (like Perl and Python) seem to have pulled it off, but it is a really difficult problem because C++ is used in so many ways on so many different platforms/tool chains.

I think we are at the dawn of cloud-based build systems where developers will see the results of their changes almost immediately. Not just being told about compile errors even before they save the file, which CLion does today (Anastasia: Actually, CLion now reports not the compile errors, but some more profound inspection cases, like unreachable code, always true/false code, etc., even including full Data Flow Analysis on the codebase), but even being told which tests are broken because of the change. I’m optimistic that we’ll have package management integration so that all I need to do is import a module and its package is downloaded, added to my repository, and the build file (which I almost never see) is updated for the module and its test suite.

Let the tools handle all of that so I can focus on algorithms.

Anastasia: Thanks Jon!

CLion 2016.2 EAP, build 162.1024.9

$
0
0

Hi,

New CLion 2016.2 EAP (build 162.1024.9) is now available for download. In case you are using previous EAP build, you can get a patch-update right in the IDE.

CLion 2016.2 EAP started with Doxygen support. It includes nice viewer, Doxygen commands and function parameters completion and comments generation. Starting from this build, you can use “///” and “//!” symbols (in addition to “/**” and “/*!”) and then Enter to generate stub that you can later fill with the documentation text:
doxygen_generation

CLion provides you with many live templates that allow you typing certain code pieces faster, using code generation. This build brings an important fix for “Applicable in” status saved correctly (IDEA-157128, CPP-6982):
applicable_live_template

Other notable changes include:

  • Time Tracking plugin was bundled into CLion. Enable it in settings Tools | Tasks | Time tracking.
  • Fix for a space used inside a format string (CPP-6873).
  • Quick Documentation (Ctrl+Q on Linux/Windows, F1 on OS X) font is now stored correctly between IDE restarts (IDEA-152590).
  • Fix for the IDE that locks on “Shelve Changes” at the “Synchronizing files…” step (IDEA-157336).

Full list of release notes is available by the link.

Your CLion Team
JetBrains
The Drive to Develop

CLion 2016.2 EAP, build 162.1120.17

$
0
0

Hi,

Another week brings another Early Access Program build with lots of goodies inside. Download the build here, or get a patch-update in the IDE (will be available soon), if you are using the previous EAP build.

Release is coming closer, so if you find any issue at all, please, report it to our tracker. Thank you in advance!

LLDB on Linux

After introducing big changes in the debugger drivers that improved performance and fixed many correctness issues, we continued working on new debugger features. CLion now goes with the LLDB on Linux (in addition to GDB) – version 3.8 is bundled into the IDE:
debug_settings

Attaching to local process thus works with both (LLDB and GDB) on Linux:
lldb_attach_linux
Note, that on Linux to use GDB for attaching to process you need GDB to be selected in Toolchains settings (this is a temporary solution, CPP-7011). On macOS attaching to process with GDB is still not possible.

Comparison, relational and stream output operators generation

CLion provides plenty of options to generate boilerplate code. In addition to constructors/destructors and getters/setters, this EAP build allows you to generate missing:

  • equality operators,
  • relational operators,
  • stream output operators.

These new options are available in the generate menu (Alt+Insert on Linux/Windows, ⌘N on macOS). Generation dialog allows you to select fields to use during the generation. In addition, you can configure:

  • if to generate all the equality/relational operators, or just == and < (this is also configurable under Editor | Code Style | C/C++ settings),
  • if to generate as class members,
  • if to generate in-place,
  • if to use std::tie for the operators implementation.

In case some of the operators are already there, CLion suggests you to add missing ones (and if all the operators are already there, you can replace all the existing with the new ones). Preview of the existing operators is available:
generation

Note, that CLion doesn’t check that class members has its own operators specified.

Doxygen improvements

We continue our work on Doxygen support in CLion. As you may already know, CLion provides you with an ability to generate Doxygen comments stub. This build brings a few settings to configure how these comments will look like. You can select if you prefer @-commands or \-commands style and if you’d like CLion to add brief tag:
editor_settings

Besides, @code/@endcode and @verbatim/@endverbatim tags are now treated as text without any changes in Quick Documentation pop-up:
doxygen_code_tag

That’s it! Full list of release notes are available by the link.

Your CLion Team
JetBrains
The Drive to Develop

CLion 2016.2 EAP: Remote GDB debug

$
0
0

Hi,

CLion 2016.2 release is just around the corner, and today we have a EAP build (162.1236.1) for you with a long-awaited feature: Remote GDB debug!

To try it download the build from our confluence page, or get a patch-update right in the IDE in case you are using previous EAP build.

Remote GDB debug

This build brings you one of the most voted feature – remote debug. To be precise, CLion now supports remote debug with GDB/gdbserver. That means that having executable running on one host under gdbserver, you can connect to it with the GDB from CLion from another host and inspect the code using all the benefits of CLion’s debugger UI: set breakpoints from the IDE, view variable values, evaluate expressions and more.

Supported platforms

Since GDB/gdbserver is a universal tool, many combinations are possible, from which most popular are debugging on various Linux targets from Linux/macOS hosts. On Windows remote debug is not supported due to several technical issues.

Configuration settings

To connect remotely with GDB to the target host, create GDB Remote Debug configuration (go to Run | Edit Configurations and create it from the template) and provide settings for the remote connection, like GDB to use, medium to carry the debugging packets (serial line, or an IP network using TCP or UDP), debug symbols, sysroot, path mappings:
remote_gdb_settings

Core functionality

Finally, simply run the executable on a target system under gdbserver (you can use built-in terminal to access the remote host). And start debugging the GDB remote debug configuration in CLion. The execution will stop on a breakpoints set from the IDE. You’ll be able to view variables, evaluate expressions, set values on the fly, check inline variable views in the editor and more:
remote_gdb_terminal

Limitations and known issues

In case you’d like to debug Linux target from macOS host, you have to use GDB version compiled with --target=x86_64-linux-gnu flag. Get the binutils-gdb sources from the Git repository, switch branch to gdb-7.11.1-release and build like this:

./configure --target=x86_64-linux-gnu —with-python --prefix=
make
make install

Then select this debugger in the remote GDB configuration.

Be aware, that in case you set this debugger to be used globally in the IDE (in Build, Execution, Deployment | Toolchains settings) local debug on macOS won’t work, so we don’t recommend you doing so.

Besides note, that in case you have sources with symlinks on your host, to make remote debug work open project in CLion using the canonical paths (CPP-7052). Another problem could happen from time to time if you have another target configured in the ‘Before Run’ section of the configuration (CPP-7171).

Please, check the new functionality in case you are interested in remote debug, and provide the feedback to us in the comment section below or in our tracker. Note, that we already have some plans about UI improvements: CPP-7011, CPP-7050.

Environment variables in CMake

Our users asked us to define a way to automatically detect that CLion is used to run the CMake command on the project. After some discussion we’ve decided to introduce special environment variable (CLION_IDE) and implement environment variables completion in CMake to make it easier for you to find it:
clion_ide_cmake
This way now you can detect CLion usage and if so, set special variables/paths or execute some additional scripts of your choice, or just add some extra logging to your CMake.

That’s it! Full list of release notes are available by the link.

Your CLion Team
JetBrains
The Drive to Develop

CLion 2016.2 Release Candidate

$
0
0

Hi everyone,

Today we are glad to announce that CLion 2016.2 Release Candidate (build 162.1236.11) is available for download. That means that the 2016.2 release is just around the corner!

We appreciate your feedback and comments, and if you find any bug at all, please file an issue in our tracker.

Previous EAP build introduced Remote GDB Debug feature, however our users on RedHat and CentOS 6 were unable to use it with the GDB bundled into CLion due to the incompatible glibc version. The problem is fixed in this build.

Please note that to use CLion 2016.2 RC you need to have an active subscription (or start a 30-day evaluation period).

Your CLion Team
JetBrains
The Drive to Develop


CLion 2016.2 released: Remote GDB debug, Doxygen support, operators generation, and more

$
0
0

As of today, CLion 2016.2 is generally available!

This is our second release of 2016, building on the idea of releasing more often and bringing you the latest features faster. With many new fantastic tools, CLion can help you become a true C++ rockstar:

  • Inspect code more efficiently thanks to improved performance of debugger drivers and the remote GDB debug possibility.
  • Keep your code well-documented with Doxygen support (and thus reduce maintainability costs).
  • Save time on typing, with lots of new code generation options.
  • Work with CMake project model more easily thanks to smart CMake support.


Download CLion 2016.2

Let’s take a closer look at these and other capabilities available in CLion 2016.2.

Debugger performance

GDB and LLDB debugger drivers have been overhauled to improve both correctness and performance. We thank all our users for your collaboration – all your logs, sample projects and use case details finally made this possible!

If you’ve ever run into ‘command timeout’ in CLion, we encourage you to get this build as the problem should be fixed now. Lots of other issues have been fixed as well: ‘Variables’ windows that wasn’t updated on variable setting, problems with showing frames, incorrect debugger exit, and more.

As an important result, debugger performance has seen a huge boost – up to 600x in some cases:
debugger_numbers

The supported GDB version was updated to 7.11 and LLDB updated to 3.8. Besides, Linux users can now benefit from using LLDB (as it was previously available on macOS only).

Remote GDB debug

It’s finally here! One of the most awaited features has finally made its way into CLion. Run an executable on a target machine under gdbserver, connect remotely using CLion remote GDB configuration, and inspect code more powerfully from the IDE’s debugger. Set breakpoints to stop at, evaluate expressions, inspect variables views, change variable values on the fly, and more. For more details about the supported platforms and configuration, see this earlier blog post.
remote_debug

Doxygen support

Documenting code is a best practice that greatly aids code maintenance and support. Now CLion helps you with this by supporting the well-known Doxygen format.

See the Doxygen documentation preview in the Quick Documentation pop-up (Ctrl+Q on Linux/Windows, F1 on macOS), navigate to the function parameters from their description in Doxygen comments, and rely on function and function parameters rename that update Doxygen references automatically:
doxygen_rename

While adding new Doxygen comments to your code base, use Doxygen commands and function parameters completion, or simply generate the stub for Doxygen comments (it will work if your function has parameters, returns a value, or throws an exception):
doxygen_generation

More details on Doxygen support in CLion can be found in this blog post.

Code generation

Saving time on typing is really easy with CLion. The many options of its ‘Generate’ menu (Alt+Insert on Linux/Windows, ⌘N on macOS) have been expanded with equality, relational and stream output operators. Select if you’d like to generate in-place, as class members, use std::tie for the implementation, and more:
operators_generation

Generate definitions (introduced in 2016.1) got updated behavior templates. Now CLion is able to adapt to the patterns you are using in your project. It can detect and support three possible patterns:

  • declarations are located in header files, definitions are in cpp-files;
  • class/struct is located in header file only; or
  • class/struct is located in cpp-file only.

If you switch from one of these patterns to another, CLion will pick up on that and behave accordingly when you use code generation the next time. More on that here.

Another way to save time on typing is the improved Complete Statement feature (Ctrl+Shift+Enter on Linux/Windows, or ⇧⌘⏎ on macOS). It helps you create syntactically correct code constructs by inserting the necessary syntax elements and getting you in position to start typing the next statement. It can complete namespaces, classes, enums, enum classes, structs and control statements:
complete_statement

Learn more about Complete Statement in this earlier blog post.

Code formatting

CLion allows you to configure plenty of code style rules that will be applied on the fly as you type, to help you keep code well-formatted and thus easy to read and maintain. The newest settings fine-tune wrapping for lines after function return type in the scope of a class, in global and namespace scopes, lambda capture list, and in ‘<<‘ and ‘>>’ operators.

Also, the list of predefined code styles has been expanded with LLVM and LLDB styles.

Smart CMake support

We keep working to make CMake easier to use in CLion. 2016.2 adds refactoring support for CMake:

  • Rename (Shift+F6 on Linux/Windows, ⇧F6 on macOS) for users symbols (like functions or macros) – all the usages will be updated accordingly.
  • Safe delete for files – related CMake commands will be updated, and a warning will appear in case of a possibly incorrect command.

To help you become a CMake guru, CLion also offers completion and navigation for user symbols, together with the new Boost-related live templates:
cmake_boost_live_template

If you want your CMake script to detect that it’s being called from CLion ( and if so, set special variables/paths or execute some additional scripts of your choice), you can now do that with the special environment variable, CLION_IDE. Environment variable completion in CMake will make the task even easier:
cmake_env_var_blog

Editor and tool windows improvements

If you a fan of fonts with ligatures (e.g. FiraCode, Hasklig, Monoid or PragmataPro), you’ll be pleased to know that CLion now supports such fonts. Simply go to Editor | Colors & Fonts | Font settings, choose a corresponding font, and select the ‘Enable font ligatures’ option:
ligatures_blog

To spice up your editor’s look, you can now set a custom background image. Use Find Action (Shift+Ctrl+A on Linux/Windows, ⇧⌘A on OS X), type Set Background Image, select an image and configure its settings in the dialog that appears:
background
Note, that you can choose different images for different projects.

If you work with long files, a new alphabetical sorting in Structure View (Alt+7) can come in handy to locate entities quicker (as opposed the reflecting the order in the original file).

Other changes

There’s a lot more in CLion 2016.2:

  • Important improvements in VCS support:
    • Files not yet under version control are now shown in the commit dialog, so you’ll never forget anything important.
    • The Log view for Git and Mercurial loads in the background on every change, so it’s always ready when you need it.
    • Patches can now be applied from the clipboard or by simply dragging them into the IDE. There’s also a Show Diff action to check the changes over your local version, and even a possibility to apply patches to files that were already moved or renamed.
    • Don’t worry about case-only renames in Git for Windows and macOS, as CLion now treats these situations correctly.
  • The Inspection results window makes it easier to preview the corresponding piece of code immediately, apply a quick-fix or disable a group of inspections in-place.
  • The maximum supported version of MinGW-w64 was updated to 5.*, and Cygwin to 2.*.
  • CLion on Windows now bundles a customized JDK version with font-rendering and focus fixes from the JetBrains team.
  • Swift plugin for CLion adds Swift 2.2 support, Introduce Variable refactoring and parameter placeholders for Swift. For more details head to the AppCode site.

To learn more, please visit the What’s new in CLion 2016.2 page on our website.


Download CLion 2016.2

Your CLion Team
JetBrains
The Drive to Develop

CLion 2016.3 roadmap

$
0
0

Hi everyone,

Last week we released CLion 2016.2, which we feel is a great update that brings many long-awaited features, like Doxygen support, operator generation and remote GDB debug.

Now it’s time to move forward. But before we share the upcoming plans with you, let us first say thanks to all our evaluators!

Special thanks

We thank all of you who evaluated CLion during the Early Access Program, provided your feedback and suggestions, and submitted issues to our tracker. You’ve made it possible to release a new feature-rich and stable version, which we hope helps you become a true C++ guru.

We’d like also to mention several contributors who deserve special kudos and a free 1-year subscription (to extend your current subscription or get a new one):

  • Neronyatkin Vitaly (YouTrack handle: neronyatkin)
  • Alexey Dmitriev (YouTrack handle: RiaD)
  • Michail Tolstoy (YouTrack handle: tolstoymv)
  • Anon Anonchik (YouTrack handle: aanonchik)

A personal message will be sent to each of you guys with details on how to obtain your license. (And just in case you do not get any email from us within a week, ping us here in the comments.)

Further plans

Here are some things we had planned for CLion 2016.2 but which will only make it into the upcoming 2016.2.x updates. These are:

  • Ability to watch command output during CMake execution.
  • Several parsing problems which lead to red code in JUCE libraries (OC-8211).

We’ve also discussed all the feedback we got from you, looked at our tracker and spent some time analyzing all these sources. This helped us come up with a preliminary plan for 2016.3.

Please note it’s a preliminary plan, so we can’t guarantee that all of the features listed below will be included in CLion 2016.3.
  • Performance:
    We feel this is a good time to put a major effort into performance improvements. If you experience any issues at all with CPU and memory usage or face any UI freezes, please let us know! Check this page for the list of dumps and snapshots that can be useful for us to investigate and localize the problem.
  • Language support:
    • Fixes to overload resolution (linked to this ticket mostly).
    • Problems with friend and using aliases.
    • Support for user-defined literals (C++11).
    • Support for C++14 digit separator.
    • If we still have resources left, we may devote some time to _Generic command (C11).
    • There is also a list of regressions that we need to go through.
  • CMake:
    • Support for add_custom_target command (if you face any problems with this command in CLion, please describe them here).
    • Ability to specify the build/generation output directory.
    • Ability to specify build types (Debug, Release, etc.).
    • Reload performance improvements.
    • Ability to select Ninja generator instead of Makefiles.
  • Debugger:
    • Remote GDB debug on Windows.
    • Disassemble view.

As before, if some features from the above are not ready for 2016.3 release (that hopefully will be available before the end of the year), they still can be delivered in 2016.3.x updates.

Stay tuned and don’t to miss the EAP launch.

Give CLion a try for free with a 30-day evaluation!

Your CLion Team

JetBrains
The Drive to Develop

CLion 2016.2.1 EAP

$
0
0

Today we are starting an Early Access Preview for CLion 2016.2.1, a bug-fix update to the recently released major CLion update. Build 162.1531.1 is now available.

This EAP includes a list of important fixes. See some highlights below.

Language support

There are a lot of fixes for false positive issues that couldn’t make its way to 2016.2, but are ready for 2016.2.1 EAP:

  • return a += b; statement was reported as unused, thus incorrect quick-fix was suggested.
  • Incorrect unreachable code warning in some try..catch cases (CPP-806).
  • Incorrect assigned but never used warning for references not used directly (CPP-3824).
  • Incorrect condition is always false warning in case of const field initialization (CPP-4289).
  • Incorrect duplicate definition in case of templates usage (CPP-6625).
  • Parser error which leads to an error with boost::none (CPP-4718).

Fixes for Project View

An error with multiple selection that was appearing in Project View after some file was deleted caused many unpleasant consequences and strange behaviour patterns (CPP-3748). We’ve fixed it now.

CMake

CMake 3.6 was bundled into this build.

Several exceptions and a regression with the project name disappeared from CLion’s welcome screen (CPP-7245) were also addressed in this build. Full release notes are available by the link.

You can download the build here and install side by side with the stable version of CLion. Please, note that this EAP build requires an active subscription (or you can start a 30-day evaluation period).

Your CLion Team

JetBrains
The Drive to Develop

Become multi-armed with CLion’s multiple cursors

$
0
0

Sometimes effectiveness is how quickly you can type. For example, having code appear simultaneously in multiple places can come in handy. In this blog post, we are going to explain how CLion can help you do this with its multiple cursors feature. We’ll also identify some scenarios when it’s better to go with refactorings or code generation instead.

Multiple cursors: Essentials

The idea is simple – you put the caret in several different places in a file and start editing all of them at once. This works for all the languages supported in CLion, including C, C++, CMake scripting, JavaScript, XML, HTML, Python, Swift and more. Sounds cool, doesn’t it?

Some useful shortcuts:

  • To add/remove a caret, press Alt+Shift and select cursor locations with the mouse. When you want to go back to single-cursor mode, just press Esc.
    Another way it to press Ctrl (Lin/Win) or (macOS) twice then hold down and move up/down, that could be useful for items that are aligned.
  • Another way to get multiple cursors in a file is to add repeating occurrences. Press Alt+J (Lin/Win) or ^G (macOS) to add the next occurrence of the current word to the selection; press Shift+Alt+J (Lin/Win) or ⇧^G (macOS) to remove one.

First option works in the situations like in the following example:
multiple_cursor_set

And second one can be handy in the case like below:
multiple_cursor_selection

If you wish to select all occurrences at once, press Shift+Ctrl+Alt+J (Lin/Win) or ^⌘G (macOS).

Multiple cursors and smart actions

Lots of editing actions work nicely with multiple cursors:

  • Move caret to line end/start: Home / End (Lin/Win) or ⌘ -> / <- (macOS)
  • Move caret to line end/start with selection: Shift + Home / End (Lin/Win) or ⇧⌘ -> / <- (macOS)
  • Move caret to next/previous word: Ctrl + -> / <- (Lin/Win) or ⌥ -> / <- (macOS)
  • Move caret to next/previous word with selection: Ctrl + Shift+ -> / <- (Lin/Win) or ⌥⇧ -> / <- (macOS)
  • Complete Statement: Ctrl+Shift+Enter (Lin/Win) or ⇧⌘⏎ (macOS)
  • And more.

Yet there are more exciting actions that work with multiple cursors as well:

  • Completion
  • Code commenting
  • Live templates

The context for the action is detected by the most recently set cursor, and the result is applied to all the cursors at once. Example:
multiple_cursor_templates_compl

When not to use multiple cursors

While the feature looks superhandy and cool, there are scenarios when it’s better to avoid it and use other IDE features instead.

Scenario 1:

If you have a class and would like to get getters and setters for its class members, don’t type them - generate them!
generate_setters_getters

Generate menu (Alt+Insert (Lin/Win) or ⌘N (macOS)) is even more powerful and allows you to get constructors/destructors, equality/relational/stream output operators, implement/override functions and generate definitions.

Scenario 2:

Use Rename refactoring to change variables, parameters, functions, macros, and other names. This will help you to:

  • Update all the occurrences and not miss any, since CLion will do it for you automatically.
  • Not break accidentally a usage placed in another scope - CLion refactorings are context-aware and ensure all changes are safe automatically.

Scenario 3:

If you find yourself changing the same value occurrences in several places, maybe it’s worth a constant, a variable, a parameter, a typedef or a define? Use extract refactorings to update the code - CLion will check all the occurrences for you:
extract_constant

Extract Function is another useful refactoring, which can save you from redundant multiple changes in similar code blocks.

Scenario 4:

If you decide to add an extra parameter to a function, you can depute function call updates to CLion - it will substitute the default value for the new parameter to the calls:
change_signature
Then you can manually update the places where you’d like to use non-default values.

The good thing about the refactorings in comparison with multiple cursors is that they work on the whole project and not just recent file.

Try multiple cursors

Give multiple cursors a try in CLion, get a feel for situations where they’re useful for you and when they’re not, and soon they will become a great new addition to your C and C++ development arsenal!

Cheers,
Your CLion Team

CLion 2016.2.1 EAP, build 162.1628.2

$
0
0

Another EAP build for CLion 2016.2.1 (162.1628.2), a bug-fix update to the recently released major CLion update, is now available for download. You can install it side by side with the stable version of CLion. Patch-update is available in case you are using the previous EAP build (162.1531.1).

This build brings several important formatter fixes:

  • Special if-else treatment formatting option can be useful:
    special_if
    however it was accidentally breaking the if-if construct. Now it works correctly.
  • Formatter preview is quite handy when you can’t guess what the option is actually responsible for, so you just try and see. This build includes a fix for a preview not updated for else spaces settings.
  • else on new line and while on new line settings are now taken into account when reformatting even if Keep when reformatting | Line breaks setting is switched on.

Thanks to our users, we’ve managed to localize a problem with Doxygen comments generation. Sometimes on big projects and large files when you typed Enter after /// and //! prefix, generation of documentation comment didn’t occur. The problem is fixed now.

Full release notes are available by the link as usual.

Please, note that this EAP build requires an active subscription (or you can start a 30-day evaluation period).

Your CLion Team

JetBrains
The Drive to Develop

Viewing all 680 articles
Browse latest View live