I'm having a problem with a Visual Studio project and IntelliSense. Since upgrading to VS 2017 (it worked fine in 2010), IntelliSense has been complaining that standard library functions do not exist (For example: time, memcpy, rand) with the error identifier "time" is undefined.
Additionally, some (but not all) standard header files give the error that they cannot be opened. For example, the source file I'm viewing right now claims cannot open source file "direct.h", while header files like winsock2.h are not a problem.
I suspect the problem lies completely within IntelliSense, since the project compiles fine and all 'unindentified' functions run and perform as expected. However, I have no idea which setting to change or how to reset IntelliSense in order to once again recognise the different identifiers.
Related
My Visual Studio 2017 15.6.7 installation doesn't display a red squiggly line under code that has errors. I'm using C++.
This happens only for a specific project in the Solution - for the rest the squiggly lines appear as expected.
I have tried to unload and reload this project, to no avail.
This happens both for header and .cpp files. I have validated that the files are part of the project.
Additionaly - it does seem that IntelliSense in general doesn't work properly for this project. The Auto Complete feature (for example, after typing a ->) does not list the correct options.
Any ideas would be appreciated.
These two trivial lines of code:
const bool equal = (HUGE_VALF == HUGE_VALF);
static_assert(equal == true, "Fatal error");
in a test program work perfectly (no warnings and no errors).
When I copy them in the main project, I get this error on the assert:
error C2057: expected constant expression
Here the equal object is a constant with value = true.
Those lines of code are in both cases inside functions.
The two projects have identical settings (C++11, Visual C++ 2013 compiler, Visual C++ 2019 IDE, /W4, no optimizations).
What could be the reason of this different behaviour from the compiler?
When a newer Visual Studio IDE (like VS 2019) loads an older project for the first time, it asks to retarget the project. If You have the old Visual Studio installed, You can reject this action. Then the compiler from the original VS will be used by the newer IDE.
After loading the solution, in the Solution Explorer next to the project name, You will have the Visual Studio which will be used to compile the project.
If the paranthesis is missing, that means the compiler and standard library from the current Visual Studio is been used.
As mentioned in the comments:
I have no parenthesis after the project name (if I am looking in the right place). However, I realised about the issue in the include file paths: Test Project: 14.24.28314\include\cmath; Main Project: Microsoft Visual Studio 12.0\VC\include\cmath, i.e. a much older version, that internally still relies on the C math.h header. So, same compiler (VS2013), different libraries...
This indicates that You have most probably retargeted the project or created a new project in VS 2019.
To make a project in VS 2019 make use of the older compiler, You need to got to the project Properties -> Configuration Properties -> General -> Platform Toolset and change it to the appropriate Visual Studio.
Also make sure that all configurations (Debug, Release,...) for all machine types (32bit, 64 bit) have this setting the same value.
Because the test project is using VS 2019 - it has all the required definitions - so it works.
So the issue is that most probably, VS 2013 standard library is not C++11 complete and does NOT have a definition for HUGE_VALF.
But it could contain a definition for HUGE_VAL
I've installed the MS VC++ compiler (standalone, not the whole Visual Studio) as a compiler kit for Qt 5.7. Whenever I attempt to build even the most basic project, I get a long list of errors, complaining about undefined symbols.
In particular, things like FLT_RADIX, FLT_MANT_DIG, FLT_DIG, etc. are undefined. I checked the header files that are part of VC (installed in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include) and noticed that cfloat (where these symbols would likely be defined) is just 284 bytes worth of zeroes. There are other header files that are in similar shape.
I tried repairing/reinstalling visualcppbuildtools_full.exe, all to no avail. How can I get a proper install?
The first install crashed and left some of the header files in a corrupt state. I manually cleared up the junk left behind by the MSVC uninstaller, then reinstalled. This fixed the problem.
Found a lot on this error already, but my case does not get matched with any yet.
I am building a solution (having many projects) in debug mode, and one of them is throwing this error, I am using VS2010 and language is C++, .net version 4.0, earlier this project was compiled in vs2008 and then VS2010, and it was all ok, now I got a new machine which has just VS2010 installed and now facing this error.
Main thing to notice is:
Properties settings:
Project Configuration->General->/CLR is chosen
In C++->General-> No CLR support
I am having these settings since past, it's running all fine in my old machine in VS2010 only in the same debug mode.
What to do?
I am using Visual Studio 2013.
I had similar symptoms for a very simple C program. In the project properties I changed the General / Platform-Toolset setting from "Visual Studio 2010" to "Visual Studio 2013 v120" and that got rid of this error for me.
As the error indicates, precompiled headers are not compatible with /clr-compiled files.
You can disable precompiled headers for the cpp files that are compiled with /clr or for the whole project (C/C++ -> Precompiled Headers -> Precompiled Header : Not Using Precompiled Headers). I'm not sure what the difference is but both seem to work for me.
Doc is not exactly wrong, but I'm betting that's not what's going on here.
Do you by any chance have something like THIS:
#using namespace boost::asio;
...instead of something like THIS?
using namespace boost::asio;
Both "using" and "#using" have valid roles in Visual Studio-- but if you mean the pure C++ language keyword, be sure you are using the former! The latter is indeed used for managed code. See here:
https://msdn.microsoft.com/en-us/library/yab9swk4.aspx
Getting this wrong in Visual Studio 2015 has the following effects:
BUILD OUTPUT:
1>thingy.cpp(3): error C2006: '#using': expected a filename, found 'namespace'
1>thingy.cpp(3): fatal error C1190: managed targeted code requires a '/clr' option
Note that attempting to "satisfy" this in a fit of 4:00 AM frustration by removing the "namespace" keyword and quoting the value will result in only the second error.
(I think that's worth mentioning, because as both Visual Studio and the C++ language specification continue to change, people try all kinds of syntax that they know shouldn't work, and if it suddenly compiles, just assume the spec or the tools have changed in some way they haven't had time to keep up with-- especially if the error messages seem to have something to do with "features" they couldn't care less about, and don't use.)
We have a very big C++ solution with several projects for which intellisense works perfectly in Visual Studio 2008, but not at all in Visual Studio 2010 (not even for structs defined in the same file where they are used). I've verified that intellisense does work in VS 2010 for other projects on my machine. I've tried importing one of the problematic projects from a brand-new solution with no success. Re-building the project files from scratch seems promising, but it would require days of work to follow that path, with no guarantee of success at the end. Any alternative suggestions are welcome. The actual error message I get is:
"Intellisense: 'No additional information available'(See 'Troubleshooting IntelliSense in C++ Projects' for further help.)
I've tried that, but there's basically only one suggestion on the MSDN webpage, to make sure "stdafx.h" on the include path, but we're not using precompiled headers and don't include it from anywhere, so I'm pretty sure that's not the problem.
Have you deleted all of the generated database (.ncb and .sdf) files? Corrupted database files is the most likely cause of Visual Studio failing to display IntelliSense.
Intellisense was not included as a component of Visual Studio 2010 for C++/CLI. Unfortunately, it seems they are not going to support it soon either. This is an incredible detriment, as i find myself having to open VS2005 on occasion to simply find an object member.
Here is Microsoft's release on the subject:
http://blogs.msdn.com/b/vcblog/archive/2011/03/03/10136696.aspx