C++ Intellisense not always working in vscode - c++

While in the middle of working on my app I had an odd issue and, while trying to figure it out, I noticed right clicking anywhere on my code doesn't give me the usual options.
The below image shows what my options are for anything that I click. I should have double or more options to choose from, like opening the document I've right clicked.
The odd issue (which may or may not be related) I had before this started happening was I that I just created a new header and source file. In the source file, VSCode was complaining that it could not find the new header file that I included. I tried including it in a different file, and it could find it there. I'm very confused as to why two files in the same directory are getting different results when they include the same header file.
Does anyone know what happened, and how to fix it?
I have restarted VSCode multiple times, as well as my computer.

I do not know how or why, but while editing code, my c++ extension was uninstalled.
Installing it again has resolved the issue.

Related

Having challenges installing pandoc-crossref in windows

I have recently started using r markdown and I am having issues with installing pandoc-crossref in window.
I have tried approaching friends on getting the set-up but to no avail. I have tried searching on the web but couldn't find anything useful. I tried following the directions here text to no avail. I will be grateful if anyone knows where i can get the set up and how to go about installing it.
You don't give any information about what errors you receive, so it is hard to provide useful help. This being said...
Trying to guess what your problem is. It is likely that you are getting the error could not find executable pandoc-crossref when trying to compile. Assuming that that is the case, your problem might be the following. Notice that pandoc-crossref.exe is not an installer, but an executable, so double clicking on it in an attempt to install it will do nothing except bring up a terminal for an instant. Is that what you have done? Where did you place it?
Leaving pandoc-crossref.exe e.g. in your downloads folder or on your Desktop would give the could not find executable pandoc-crossref error when trying to compile, because the executable needs to be in your $PATH, or pandoc will not be able to find it and run it.
A possible solution. If my guesses above are correct, you might be able to solve your problem by placing pandoc-crossref.exe inside your pandoc program folder, where your pandoc.exe file is, which is by default in:
C:\Program Files\Pandoc\
So try to place pandoc-crossref.exe in that folder and see if it works.
If this does not help. Say exactly what it is that you tried to do, what errors you encountered, and maybe include a screenshot.

How to compile/migrate a Visual Studio solution from a machine to another?

Recently I obtained a solution which has been created on another person's machine. I have been banging my head into the monitor in the past 2 days trying to fully migrate the solution to my machine. I have been manually changing the directory addresses of the solution and have not been able to compile the solution although I think I have corrected more than 100 paths as of now. Here's my first attempts to migrate the solution to my machine and resolve the issue of not being able to open any of the files.
Now I can open all the files in each project on my machine (after manually changing their paths). However, I am still getting the same errors and I'm not able to compile the project. Below is a picture of the errors I'm getting:
And here's the output log when trying to compile the project. So I wonder, can someone give me some advise on how I should go about doing the whole process automatically? In the output log I see there is a F:\Virtual ... path which indicates the solution been created on a virtual machine. However, I am not using a virtual machine and am not able to find the file file containing that path (F:...) so that I can change it to the correct one (I even do not know what the correct one should be since I am not using a VM).
If you are not able to help me through the description I gave or the output log file, you can download the whole solution from here and then give me some instructions on how I should go about compiling and using it. I really appreciate your help.
Chances are that someone went rogue on the project file, because normally all paths are defined in a way that is relative to the project or solution, making them portable.
In order to fix this, I see two options, either set up the project files from scratch or keep on hacking on them until they compile. Whichever path you take, keep in mind that VS supports placeholders like $(SolutionDir) you can refer to when setting up paths. If that doesn't work, please try to extract a minimal example.
Also, make sure you have a version control system set up, so you can retrace your steps. This should be standard in any software development, but considering the state of the project I wouldn't be surprised to find other, hairy places there.

Include files are not being recognized, even though they are in the right directory?

This is my first post on here, but from what I've seen, you guys like precise and concise problems. I think this qualifies. I have googled hi and lo and might have a case of the dumb, but cannot solve this.
I'm trying to compile a program I found that uses the portaudio library. I downloaded all of them, and HAVE all the relevant files, but visual studio is giving me issues.
This is the error I get:
So, I decided found the source path, and tracked down the file, which was in a different folder in portaudio, and copy/pasted it in the appropriate location (can't post third link, but it's there. I can provide that in the comments if necessary, I suppose). . I also have tried putting it in the same directory as the file that actually includes it, adding it to the project as an existing item, and adding that entire directory to the preprocessor include things (project settings > c++ > general > additional include directories).
The second error is very similar and is basically doing the same thing. I have the file, put it in the right place, visual studio can't find it.
Thank you all for your help.
One possible answer to your problem is that you don't have the right permissions. Are you able to open the file in a text editor?
I ended up figuring it out. For the second error, I had to save the .c file to .cpp through visual studio instead of just changing the extension. For the first one, I'm honestly not sure what I did, but it just sort of fixed itself. Such is the magic of programming, I suppose.

Eclipse CDT Showing False Error Icons

Eclipse CDT frequently shows many error icons in front of file names which suggest the code analyser discovered some errors. However, upon opening the file, the error icon disappear! This seems to happen after I run the Code Analyser and/or the Indexer, and it seems to happen on all files. This is really annoying because it makes the icons useless as I cannot tell from the icons whether the files have errors or not; I have to open all files one by one to know which files have problems. Any idea why this is happening and how to fix it? Thanks!
Try rebuilding index, and then close and open project to force icon refresh.
If this doesn't fix the issue. You shall check if the include paths are valid.

Visual C++ Build / Debugging Issue

I'm having a weird problem with Visual Studio. Whenever I change my code and build, even though I get the notification that the built was successful (and if any, it also shows errors in code and doesn't build) the executable is actually the previous build. This is getting really annoying and frustrating.
If I put a breakpoint on the new lines, the breakpoint gets disabled and it says
The breakpoint will not currently be hit. No executable code is
associated with this line. Possible causes include: preprocessor
directive or compiler/linker optimization
If I put a breakpoint on old lines of code, it stops processing but shows me this message
The source is different from when the module was built. Would you like
the debugger to use it anyway?
I never had this problem before and the source code in on my laptop's hard drive. It saves right away. The only way to get around this to Clean the entire solution manually every time, instead of basically pressing F5.
Thanks everyone for their suggestions. My mistake was that I defined the classes inside .cpp files, this somehow caused the linker to do weird (caching probably) stuff and link the old objects. I renamed the file to .h and everything's working as expected.
Perhaps your code is not built, or is built in a way you don't expect.
You might check by inserting a #error foobar preprocessor directive somewhere. If no error shows when building, you know you are in trouble!
But I never used Visual Studio (I'm only using Linux) so I cannot help more.
It might be that you have set main project some other project and building that.
make your project that you want to work on as "Main Project " by set main project available in menu bar.
I think you are using source files from another project (ex: if you are using a dll say, my.dll (which was built using some source files say, mycpp.cpp ); in your current project).
When you debugged into the file (mycpp.cpp), maybe you modified it.
Hence you need to rebuild the dll (my.dll) first in the project in which you created my.dll .
Or
Maybe you have opened a instance of mycpp.cpp in a window & debugging in another window.
you should rebuild the dll.
If you are not using files from another project, then I cant guess the cause...but still I would recommend using rebuild rather than clean & build.
please clarify your Question a bit.
#David expecting a reply from you...
I was looking for an answer to this issue since I was also stuck with it. A colleague of mine just gave me a solution that works. Yes, it seems really stupid, but it did the trick for me.
Our solution has many projects. He told me to select the project that I wish to break into and set it as the startup project (right-click on the project name and pick "Set as startup project"). I was desperate, so I tried. To my amazement, it works.
Since I have this window opened, I thought I'd share it in case someone else is stuck with the problem.
I faced the same problem. But reason was not as yours.
Then I just restarted the visual studio and it ran as expected.