Visual studio code Linux - Squiggle lines don't show up on .h files, but work well on .cpp files - linux

I noticed that somehow VS Code C/C++ Intellisense is not working on .h files. But they work pretty well on .cpp files.
I tried all the header files are not showing any errors, and it starts to be really furstrating, because it doesn't show if I mistype something.
I have installed the C/C++ extension by Microsoft.
Why is this happening?
I checked the settings but didn't find any good solutions there.

Related

How to inspect an external .cpp file?

I have in the project a cpp file that is outside the dir tree. Resharper c++ doesn't enable inspection, such as go to definition.
Resharper version 2022.1.2
Visual studio 2019 and 2022
It didn't help enabling
options> code editing> c++> inspection> enable on external modules
Also, it's not an external file, it's a cpp that is part of the project.
There's also this
https://www.jetbrains.com/help/resharper/Reference__Options__Tools__External_Sources.html
but the option doesn't appear under tools.
The problem is with resharper; VS inspection (go to definition) works fine.
I found the problem, and it's weird. Say I want to add to the project the file:
c:\prj\confstruct\src\debug\mpir.cpp
which is outside the project directory.
If in cmake I use the abs path (given as a parameter to add_executable):
/prj/confstruct/src/debug/mpir.cpp
then resharper ignores the file.
If I add the drive letter:
c:/prj/confstruct/src/debug/mpir.cpp
Then resharper works fine.
Make sure that the file is used somewhere in your project, i.e. is included into one of your .cpp files. Turn on the "Enable inspections, quick fixes and context actions in files external to the solution" option in ReSharper settings:

Is this possible in Visual studio 2010 c++ to run different .cpp files using different buttons of Windows Form Application?

I am using visual studio 2010 Professional and made some .cpp files using Win32 Console c++.
All the files are under same project like for training and testing,etc.
Now is it possible that I make different buttons on windows form application to run these different .cpp files just by clicking buttons like for training,testing,etc.
I tried to do this but the error is coming because CLR is not compatible with /MT,/MTd,**etc although I have tried to change the Properties.Also I am using VC++ in all **.cpp files and form application produce C# code on Double clicking it.This could also be the reason of error.
Whenever I run a .cpp file I exclude all other .cpp files to build that otherwise the Build is failed.I am new to this so kindly guide me. Moreover, all .cpp files have their own main() function.
Do not keep multiple main functions. One program should have only one entry point.
What do you mean by "running the .cpp files"? When a project is compiled, all the source files are by default compiled. You can "call" functions that are defined in different .cpp files.
As for buttons for testing, you can assign different buttons to call different functions.
I hope that solves your problem.

Loading Boost 1.40.0 into Intellisense in Visual Studio 2005?

Is there any way to get Intellisense in Visual C++ for Visual Studio 2005?
I'm trying to get the Boost libraries to load up with intellisense and in the object browser/class view.
I installed the binary for Windows with the BoostPro installer (BoostPro 1.40.0 Installer).
I'm not certain that it comes with the source code however, which may be required to make Intellisense work in VS2005.
Boost is open source, and mostly header only. Just make sure IntelliSense knows the directory where boost resides so it can explore it.
As an un-answer, you might try out Visual Assist X, which works far better and has more features that Visual Studio's IS.
To make sure Intellisense can find boost, just make sure Boost is in the include directories (under Project Properties->C/C++->Additional Include Directories). Maybe move it to the top. After that, close your instance of Visual Studio, and search the a *.ncb file near your project, and delete it. This will cause IntelliSense to refresh. This should hopefully be enough for it to assist you. (You have to include boost headers into your source files with #include for IntelliSense to consider it)
Keep in mind boost has some very complex parts that IS will choke on, but should still provide the names.
Intellisense scans the headers #included in source files in Visual C++ projects.
So create a project with a single source file that includes the top level header of the boost library that you're interested in. Some of the boost code can't be parsed by intellisense though, and the boost code contains a lot of code to workaround language or compiler limitations that's just noise to someone wanting to see the user facing structure of the libraries.

C++ ODBC problem with sqlucode.h header

I found a great C++/ODBC example here...
The project I downloaded builds great and everything works. However, when I copy the .cpp and .h files into another project, I seem to have a linking problem.
The SQLConnect function in sql.h is the one I want. When I right-click this function in the easyodbc.h file in the project I downloaded, it jumps to the declaration in sql.h. Life is good.
However, in the project I created, when I do this it jumps to a UNICODE definition in sqlucode.h. This seems to be causing problems and my test project crashes.
I don't have an #include for sqlucdode.h anywhere in my project, yet it still resolves the declaration to the one in sqlucode.h. How can I prevent this? Thanks.
Seems like you have a preprocessor problem rather than a linking problem.
You probably have a preprocessor definition for UNICODE (or _UNICODE) in your project file. In Visual C++ 2005 and 2008 you can fix this by going to your project properties and changing Character Set from Use Unicode Character Set to Use Multi-Byte Character Set. When you apply this setting, Visual Studio fixes up the right preprocessor and linker settings for you.
If you have an earlier version of Visual Studio you can still fix it by changing the preprocessor definitions for UNICODE and _UNICODE to _MBCS - it's just you'll have to find them yourself.
EDIT: I just downloaded that example code and tried it - good news, it's exactly as I guessed, change to a multibyte character set and you'll be fine.

Strange Dependency Behavior in VS.NET 2005 (Unnecessary .CPP Compilation)

I work on a large Visual C++ (MFC) project in VS.NET 2005.
I have noticed strange behavior in Visual C++ 2005. Often, I will change one line of code in a .CPP file but many .CPP files will compile as a result of this. I have never seen this until VS.NET 2005. Theortically, changing a line of code in a .CPP file should simply require recompilation of that .CPP file and re-linking of the PE file.
What am I not understanding about the build process.
I found this link helpful when solving a similar problem, was under pressure at the time, I tried a few things and the issue went away, for the life of me I don't know (or can't remember) which - if any - helped.
Hope this helps
This is a strange bug in the VS2005 dependency behavior. To find out one suggestion would be to take the following steps:
Go to Tools -> Options ->
Projects and Solutions -> Build and
Run -> MSBuild Project Build output
Verbosity and select Detailed
Compile your project.
This will give you a detailed output of the build which "may" help you arrive at a solution to your problem.

Resources