Does anyone know how to enable C++11 support in Gimpel flexelint?
To achieve the same as the option -std=c++11 in the GCC compiler
You can turn it on with -A(C++11) flag
The generic way to turn on a wanted standard is: -A(C++year)
Related
I am working on a project that uses a GCC library (SFML), which is not available for clang, as far as I know. I am using COC with vim for code completions, but for C++ it needs clangd. Is there a way to use GCC as my compiler, but still use the clangd language server?
I have also heard that there may be a way to make clang recognize GCC libraries/headers, but I've never been able to make it work right. If somebody could point me in the right direction there that would be helpfull too. But I'm used to GCC (I've been using it since I started programming C++), so being able to use clangd and GCC would be preferable.
Yes it is. I do it with ccls (which is clang based as well).
Given my installation of clang is not the standard one (I compile it, tune it to use libc++ by default, and I install it somewhere in my personal space) I have to inject paths to header files known by clang but unknown by other clang based tools.
I obtain them with
clang++ -E -xc++ - -Wp,-v < /dev/null
Regarding the other options related to the current project, I make sure to have a compile_commands.json compilation database (generated by CMake, or bear if I have no other choice), and ccls can work from there. I expect clangd to be quite similar in these aspects.
Ops, answered the wrong question.
But for those who use ccls:
create a .ccls file in your project directory and append --gcc-toolchain=/usr to it.
use this tool to generate a compile_commands.json file
see https://github.com/MaskRay/ccls/wiki/FAQ#compiling-with-gcc
I struggled to find a clear answer on the first Google page.
I have troubles understanding the term "Language standard". I mean, the new standard should be implemented on a software level, right? It's not just a list of things discovered that users can now do, right?
I use delegating constructors, get a warning:
[Warning] delegating constructors only available with -std=c++11 or -std=gnu++11
Though things seem to work the way I want them to. Is such warning critical? If so, how do I get rid of it?
Dev-Cpp is just IDE (frontend) for coder and behind it sits MinGW with GCC 4.9.2 as compiler*. So every time you click "Run" or "Build" it is GCC to do the dirty job. GCC by default uses C++03 standard and to use newer one you have to tell it explicitly via compiler flag -std=c++11. You can change it in Tools->Compiler Options->Settings->Code generation->Language standard (-std).
I am not sure why delegating constructors could work without C++11 (probably some GCC feature), but for sure you will not be able to use C++11 libraries without -std=c++11. It will also get rid of the warning.
(* Assuming you used default Dev-C++ installer.)
I'm trying to introduce using CMake to build my C++ project. When I run make I get an error :
[ 11%] Building CXX object CMakeFiles/game.dir/InputHandler.cpp.o
In file included from /usr/include/c++/5/unordered_map:35:0,
...
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support...
I realise this is because CMake is not invoking C++11 when it needs to in order to enable the use of the unordered_map. After googling I know I need to use target_compile_features() in my CMakeLists.txt. But I can't find anywhere which gives me the syntax/arguments I need to use, there's just examples e.g. on the CMake page it gives :
add_library(mylib requires_constexpr.cpp)
target_compile_features(mylib PRIVATE cxx_constexpr)
But I don't need cxx_constexpr, I don't even know what that is. I need unordered_map.
Can anyone tell me the syntax I need to use please, preferably giving me some sort of reference to valid values to pass into that function.
std::unordered_map is part of the STL, it isn't a language keyword like constexpr or override, etc. CMake doesn't provide compile features for STL functionality (that would be an overwhelming task to implement!). In your case, you really just want to tell CMake that you need C++11. This article provides all the details you should need on this topic, but to summarise it for this particular question, adding the following near the top of your CMakeLists.txt file should give you what you need:
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
GCC and clang let you compile with -w to disable all warnings, but I can't see a #pragma equivalent of it. I can see only pragma support for disabling individual files.
I need this because I have code that I want to compile with high warning levels but which necessarily compiles third party code which generates arbitrary warnings.
You can kind of do it with GCC, almost, using #pragma GCC diagnostic ignored, but unluckily not very well, see here.
The problem is that you cannot just "disable all", you have to disable each single one. Plus, for some warnings it doesn't work (and the docs don't tell you which ones...).
My guess is that this somewhat preliminary and will (hopefully) be improved in the next version.
I am wondering if there is a way to find out which g++ compiler/linker flags where used in creating a binary-only library.
For example there might be a 3rd party shared library (only .h/.so files are there).
So I think it would be a good idea to use the same g++ flags when compiling and linking my own application (that is using the binary-only 3rd party library).
Specifically I am asking for compiler flags like
-fno-inline
-pthreads
-mtune=arch
-O2
and also it would be of interest which linker flags have been used:
-fpic or -fPIC
-fexceptions
-pthreads
and so on.
There is no systematic way of doing this. You can look if the library is linked to libpthread as an indication of whether -pthreads was used. For PIC/non-PIC code, you may want to try this. Optimization level, tuning and others will be much harder to determine.
I don't believe so as there does not appear to be a section in the ELF format for that information. On Linux, if you use 'readelf -a' to dump all the information, there's nothing about how the file got that way.