I'm a new user of CLion (version 2020.2), writing C++ code.
CLion has some sort of Doxygen support - it's willing to "render" Doxygen and present the rendered comment in a side-pane. However, within the code itself, the Doxygen comments have the same font and color as regular comments.
I know that in Eclipse, the preferences has an option you can set which sets Doxygen comments to a different color. Is there something equivalent in CLion?
Note: A plugin would be fine; but I couldn't find a relevant one, searching for "Doxygen".
tl;dr: Upgrade to CLion 2020.3 or better yet 2021.2 .
I have this running in version 2020.3:
They have also recently fixed a bug with this feature in version 2021.2 EAP.
You basically go to your Settings and go into Editor | Color Scheme | Language Default and there you'll find the "Comments | Doc Comment" section.
you can specify different colors for doxygen comments, and even different handling of different sections of your doxygen comments
Related
The provided documentation for the basic c++ packages within clion seems to be very short, and sometimes it is not possible to find any documentation for basic functions like e.g. the tangens function of the math package.
Is it somehow possible to include the offline-version of cppreference.com into clion's doxygen-based documentation viewer?
At the moment CLion doesn't support such functionality, here's the ticket for that https://youtrack.jetbrains.com/issue/CPP-9413.
As workaround, in case you use Linux you can install standard library with documentation, for instance:
https://packages.debian.org/sid/libstdc++-6-doc
https://packages.debian.org/sid/glibc-doc
After that CLion will have to work with lib-sources which documentation comments.
I want to have google-style like code style checker that would automatically run within Clion.
However, what I found as solutions (predeclared code style for google and others, direct Editor settings and EditorConfig support in Clion help) are all rather primitive. For example, I want to use snake case with final underscore for class member fileds (e.g. my_class_member_) and usual snake case for function arguments (e.g. some_argument), and none of the suggested options would do the trick as far as I am concerned. Furthermore, some politics associated with endless loops and so are to be added, which is even more context-specific.
I consider creating cpplint.py-like script for this, but it is going to be very time-consuming and is likely to be run outside Clion. Are there any elegant ways to solve my problem?
Yeah, you able to do this! Look into Clion plug-in Clion-cpplint and use with cpplint.py script, provided by Google. You will get highlights on the fly when you are editing C++ source code.
You able to install add-on through Plugins tab in settings. In the end you will get something like:
I have a function documented like this:
/**
* Does something useful
*/
int foo(Bar bar)
{
// my function
}
But Intellisense doesn't display it when i hover the function in other places. When i hover it at the definition, i see * Does something useful, which isn't right either (the star should not be in there). Doxygen runs fine and eclipse CDT displays the doc comments as you would expect.
As of version 2016.2, JetBrains ReSharper provides support for Doxygen documents in C++ files. From this blog post I quote:
Doxygen is arguably the most popular format and tool for code
documentation in the C++ world. ReSharper C++ now understands Doxygen
syntax, and provides several key features to facilitate editing of
documentation blocks.
Typing assist helps with creating new comment blocks and maintaining the
structure of existing ones.
Code completion suggests Doxygen commands with accompanying short descriptions.
Function parameter references introduced with \param commands will be reported by Find Usages and will get updated when Rename is used to change a function parameter’s name.
Warnings are issued when function parameter references do not resolve to an existing function parameter.
Documentation generation: You can now generate documentation for C++ declarators, classes and macro definitions.
Quick Documentation: Documentation now works in C++. The documentation pop-up (bound to Ctrl+Shift+F1 in the Visual Studio scheme or Ctrl+Q in the IntelliJ IDEA scheme) will display documentation from Doxygen comment blocks, or the symbol’s signature if no documentation is found.
It should be noted that this product is not free and to use it, you need to procure a license.
Is there a way to sort my #include statements in Clion? Additionally, can I do this automatically every time I save? I didn't manage to find any such functionality or plugin.
Yes, it is possible with help of clang-format.
File->Settings...->Languages & Framework->C/C++->Clangd->Enable clangs server
clang-format should be installed in your system. Normally it is available in your favourite repository. You can specify the path to it if required
File->Settings...->Tools->clang-format
You have to put .clang-format file into your project root with coding rules. More information you can find on clang-format web site. For example, I am using Google coding rules. My content looks like this:
Language: Cpp
BasedOnStyle: Google
This includes already the include statements sorting. However, there is a choice of other ready-to-use coding styles like LLVM, Mozilla, WebKit, Chromium which you can use and if necessary modify or you can create your own format by providing set of rules you want. The rule you might be interesting in is
SortIncludes (bool)
If true, clang-format will sort #includes.
Please refer to the clang format documentation here
There seem to a variety of questions like this one without any clear solution that is true for Xcode 7 (or even other versions of Xcode).
I have a version of GCC that I'd like Xcode to use when it compiles. It is not the standard GCC but customized for a different platform. I can specify and use this compiler fine in Eclipse, but would rather use Xcode. The Build Options only list LLVM and nothing else. When I try to add via "other" in that section, all I get is this empty popup:
What goes in this box? I would think that it should be no big deal for Xcode to simply use a GCC that I have available at a specific path on my system, but this appears to be quite complex.
Update: Apparently there is a supported mechanism for installing externally-provided tool chains in Xcode that I wasn't aware of. For example, one can download packages from swift.org that install alternative tool chain packages into /Library/Developer/Toolchains or ~/Library/Developer/Toolchains. Once one of those is installed, Xcode has a GUI option to switch the active tool chain.
There was a recent change to the Swift sources to include a script for building one's own custom tool chain from them.
If you view the Quick Help for that build setting (View > Utilities > Show Quick Help Inspector) or configure the build settings view to show setting names instead of titles (Editor > Show Setting Names), you'll see that that setting is GCC_VERSION.
If you look that up in the Build Settings Reference, you find:
GCC_VERSION
Description:
Numeric identifier. Identifies the GCC version to be used to compile
the target’s source files. When the target’s “System C rule” is set to
GCC System Version (instead of a specific version number), this build
setting is not available in Run Script build phases.
Values:
2.95.2
3.1
3.3
4.0
Default value:
GCC system version.
Specified in:
Project Info > Rules > “System C rule.”
Target Info > Rules > “System C rule.”
Affects:
GCC_VERSION_IDENTIFIER.
That's actually a bit out of date. It says it's specified by fiddling with a build rule (not setting) called the "System C rule". You used to change the version there but now there's a direct build setting for it.
Anyway, this probably doesn't help you do what you want to do. I doubt there's any value you could put in there that would do something useful, let alone use a third-party compiler.
However, the explanation does have a hint. It mentions the System C build rule. You could modify the build rules on the Build Rules tab of the target configuration screen. You can find the System C rule and press the button to copy it to your target, which will let you specify a custom script to process C files (including Objective-C and C++).
Implementing such a script is non-trivial. The inputs, expected outputs, and required behavior of the script are not well documented. There are various environment variables available for the use of such a script. Some are the build settings. You'll need to translate the relevant settings into compiler options. For example, translate the CLANG_WARN_BOOL_CONVERSION setting into the corresponding -Wbool-conversion option.
Some of the other environment variables indicate which file you should operate on, such as INPUT_FILE_PATH, INPUT_FILE_NAME, etc.
You need to tell Xcode what file(s) your rule outputs. These can be based on the input environment variables/settings, such as $(OBJECT_FILE_DIR)-$(CURRENT_VARIANT)/$(CURRENT_ARCH)/$(INPUT_FILE_BASE).o.
In general, this is just not something that Xcode makes easy.
Someone wrote a plugin that will allow you to use gcc from Xcode.
http://hamelot.io/programming/add-gcc-compiler-to-xcode-6/
If you have a custom gcc then you would need to change the paths around etc but the plugin should work.