Are standard library warnings normal? - c++

I'm learning my way around visual studio at the moment. If I've turned set /Wall I'll be greeted with a seemingly unhealthy amount of warning messages although my application will compile just fine.
Is this normal? Changing the error level will stop the messages. It looks as if they are all related to the C++ STL or its header files - same thing?
If I build the program using code::blocks (GCC) then no errors are reported despite the same warning level.
What's going on here?
update:
visual studio /Wall output: http://pastebin.com/FBGLd2Hb
visual studio /W4 output: http://pastebin.com/YuWKVS9G
The code is actually from Wrox Professional C++.
I could be wrong about my usage of the word warnings?

With g++ -Wall does not turn on all warnings, just a practical subset. I suspect that with MSVC /Wall turns on more warnings than is practical. MSVC is very enthusiastic about warnings.
With MSVC use /W4 for high warning level.
You'll have to turn off MSVC sillywarnings; you can use my anti-MSVC-sillywarnings header for that.
Cheers & hth.,

Related

How to make Visual Studio IntelliSense (code completion) recognize Clang extension primitives

I would like to use __fp16 (a Clang language extension) in Visual Studio, but the code is highlighted red by the Visual Studio's code completion whenever I do so. I know that my version of Clang (5_0) supports this extension, and have successfully compiled code using __fp16, but I find that IntelliSense recognizing __fp16 as an error is inconvenient and makes finding errors more difficult. Is there any way for me to configure Visual Studio's IntelliSense so that it stops marking __fp16 as an error? Thank you.

Which test-coverge tool for Microsoft Visual Studio Compiler?

The main product of our organization has been developed(and being developed) in C/C++ over the past 10 years. The compiler used is Microsoft Visual Studio (cl) for the same.
We need a test-coverage tool (identical to gcov) for checking the coverage of the code. As per my understanding, gcov only works with g++ family of compilers and hence will not work with Visual Studio's compiler. (please correct me if I'm wrong).
Now, since we can't change the compiler; please suggest a test-coverage tool which will work in our case.
Thanks.

Can I use GCC's / LLVM's STL headers with VS?

I am using MSVC++ 2013, and I installed the Clang plugin.
However, since I'm using STL, I'm getting bugs like this one:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\map:6:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtree(1667,3) : error: cannot compile this try statement yet
_TRY_BEGIN
^~~~~~~~~~
They are quite a lot. In fact, there's only problems on the header files -- and it's what has me confused.
Is this an actual compiler bug? Incompatibility with MS' STL implementation?
If so, can I fix it, and how?
I thought of using GCC's or LLVM's headers, but I don't know how -- any pointers would be greatly appreciated.
Since you insist the environment is set up right, I looked up that exact macro that's not understood. That particular error can occur when the MSVC headers themselves include xstddef when _HAS_EXCEPTIONS is defined as 0. I can't find any other conditions on that macro, so it appears that your clang is compiling without exceptions.
This rings a bell in my head, and Clang had problems with exceptions for a long time on windows. Occording to this link, it still does in MSVC compatability mode: "Exceptions and SEH: Minimal. Clang can parse both constructs, but does not know how to emit compatible handlers. Clang cannot throw exceptions but it can rethrow them." http://clang.llvm.org/docs/MSVCCompatibility.html
I don't think llvm's libc++ can be compiled with msvc. Your best bet would be to try to use LLVM to produce MSVC compatible code that can (in theory) be linked with Visual C++ compiled code.
http://clang.llvm.org/docs/MSVCCompatibility.html

Background compile in VS2010 and C/C++

I use Visual Studio 2010 and Intel icc compiler for C development. I use C99 but editor is still showing C99 constructs as errors (compiling is fine). How to get rid of it?
Second question, is it possible to use Eclipse (CDT) with Intel compiler on Windows?
As mentioned in the responses to your post, the problem you're seeing is with your intellisense only.
You can turn off intellisense error reporting in VS2010:
Tools > Options > Text Editor > C/C++ > Advanced. Under IntelliSense, choose "Disable Error Reporting" and set it to "True".

What Visual C++ setting/option/flag is the counterpart of -ansi -pedantic in g++

I have a C++ codebase, and I am porting from Visual Studio to g++, which should I set in Visual Studio so that build errors in gcc are reduced? With g++ this is achieved by -ansi -pedantic.
I believe you are looking for /Za.
You should probably set the highest warning level /W4 and also disable the MS specific language extensions, /Za. Also check that you're using the for loop scope option /Zc:forScope
The only real way to do this is to compile under VStudio AND under GCC. GCC can be a lot more pedantic than VStudio :)