C++ error detection in Visual Studio 2005 - c++

Coming from a different development environment (Java, mostly) I'm trying to make analogies to habits I'm used to.
I'm working with a C++ project in Visual Studio 2005, the project takes ~10 minutes to compile after changes. It seems odd that if I make a small syntactical error, I need to wait a few good minutes to get a feedback on that from the compiler, when running the entire project build.
Eclipse gave me the habit that if I make some small change I will immediately get a compiler error with an underline showing the error. Seems reasonable enough that VS should be able to do this.
Is this something I can enable in VS or do I need an external plug-in for this?

The feature you are asking for will be available in Visual Studio 2010. Here is a detailed link of the feature details that will be available.
For now, as others have suggested, you can use Visual Assist which can help a little bit.
These are called Squiggles BTW.

You can try the following:
install a plugin like Visual Assist: it will notify you about most of the errors;
if you want to check yourself, use Ctrl-F7 to compile the file you are currently editing - in such case, you will not need to wait for all project to compile. If you are editing a header file, compile one of the .cpp files it is included in.

Yes, C++ is notorious for its build times. Visual Studio cannot perform on-the-fly syntax checking (in case of C++), but you can install Visual Assist to help with that:
(source: wholetomato.com)

10 minutes is quite a long time to wait, are you doing a full build every time? There are a lot of techniques you can use to speed this up, for example using precompiled headers. I try to organise my code so that I do all of my significant changes in the code file instead of the header, then just do a build of that one file (ctrl F7) to check for errors.

You have the "error list window" that will list your errors and warnings after compilation. If you double click on the error it will directly go to the problematic line of code in your source. It's in the menu Display, sub menu "Other windows".
Keep in mind that compiling C++ is a much more difficult task than compiling Java, which explains the increased time.
Visual Assist X is very cool but only detects typos.
It cannot be compiled "on the fly" which explain the feature you ask is not possible. If you have a multicore machine, you can enable parallel building.
Tools -> Options -> Projects and solutions -> Generate and Execute -> maximum number of parallel compilation.

Resharper for C# has it. But for c++, maybe visual assist x ?

Eclipse gave me the habit that if I make some small change I will immediately get a compiler error with an underline showing the error. Seems reasonable enough that VS should be able to do this.
Eclipse has implemented their own Java compiler, and run that in the background every time you type a word to be able to detect and underline errors. I don't know if I'd call that "reasonable". ;)
It's a lot of work to implement that feature, even in a simple language like Java.
In C++, where, as you've discovered, compiles may take minutes, it's harder still.
Visual Studio 2010 is going to implement this feature (again, using a separate compiler, which is much stripped down, and won't always provide correct results -- that's the compromise necessary to ensure that it's fast enough to compile on the fly).

Related

Visual Studio cannot start debugging for C++ project 0x80070057

Randomly (and infrequently), Visual Studio (2017) will abruptly refuse to run my C++ project. This will suddenly start happening in the middle of a session.
Visual Studio will still build the project and generate the executable, however, the following cryptic error message appears every time I want to run my program. No changes were made to the configuration or project and it strangely happens after an innocent build.
(It goes without saying but I tried extensively checking for solutions to this problem and no solution worked or was applicable)
Whether I add a new configuration setting or play with the existing settings (Release/Debug, x86/x64), nothing fixes it except performing a full repair (and that takes a very long time). Creating a new project didn't help either, but running it in VS 2015 is successful.
This happens approximately once a week, so I would greatly appreciate knowing how this error can be fixed (or at least avoided).
After some more experience with it, it appears just to be an issue with Visual Studio when builds are too large and executed too often (it happened to multiple computers). More specifically, it could come about as a result of using many templates and applying a large number of explicit template specializations. By building with only the template specializations I need for testing, the issue doesn't come up.
This is usually caused by VS mixing release and debug binaries for me. I have a script which cleans all the output directories, including the garbage VS puts into the projects .vs and Windows Temp folder. This always fixes the issue for me.

Visual Studio Code First C++ Project

I'm investigating using VS Code for our current C++ project on Linux (using gcc to compile). Though I'm familiar with Visual Studio, Visual Studio Code is a different beast. I'm just trying to get a sample C++ app up in it, but even following this simple tutorial has proved fruitless.
It all falls apart early on. I have a one file program open. When I bring up the command palette, I don't have the "Tasks: Configure Task Runner" task. Since all the following steps depend on this one, I don't know how to proceed.
Was that command removed? Is there a better/more current step-by-step guide? I've heard great things about VS Code and really want to get it working.

Win32 application (VS2010) runs much slow then a console in Eclipse (c++)

I have a project which I created in Eclipse c++. The project invokes a function that does a lot of loops (Thousands) to calculate the result.
When I run it in Eclipse it takes 1 minute (~70 seconds).
I wanted to add a GUI to the project so I opened a WinForm (Win32) project in VisualStudio2010 and moved all files of the project from the eclipse directory to the new directory (created for VS2010).
Now, when I run the form, the function takes 4-5 minutes. I tried to cancel the progress bar but it wasn't the problem, so I understood that long time is not because of the GUI.
I think the problem is in the compilation in VS2010. I tried to change some Optimizations properties, but the project couldn't be compiled...
How can I reduce the run time?
Thanks!
Basically you answered your own question:
I think the problem is in the compilation in VS2010. I tried to change
some Optimizations properties, but the project couldn't be compiled...
however, it's hard to answer it, since there is a lot of optimization options in both of compilers, it's hard to tell what option makes it much faster/slower. It's also possible (and most probably is) that MS compiler just cant produce exactly the same or similar code to that of Eclipse's compiler.
Your options is to "play" with optimization switches of the VS compiler and see if it helps. You can try to compare it's options to ones of the Eclipse to find differences, but most likely they will be just too different.
As #Zuljin correctly mentioned also check you selected Win32 project, not CLR (Windows Forms) application. If you are using CLR project, then it's natural it will possibly run slower than Native program type.
My bet would be the debugger in VS2010
Build with your optimized settings but then start the generated file from the explorer, not from Visual Studio. You can also deactivate the debugger attachment in the project settings.
See if the run time is any different.

visual studio 2010 c++ load time

This is probably way too vague for any concrete answers, but this issue has been bothering me so I figured I'd give it a shot here:
Every time I hit F5 to run a project (and I'm talking something tiny 2 - 3 source files), first of all half the time it tells me that I need to rebuild the project even if the only change I made was add a breakpoint and then takes maybe ~20s to actually get the program running. This is a very basic command-line program and with gcc everything happens much, much faster. Any ideas?
PM
When using VS2010 on older operating systems (Like WinXP), then one should make sure to install latest UIA (Windows Automation) component MS KB971513. Failing to do this will cause VS2010 to perform poorly.
Also check ScottGu's Blog for other important hotfixes
The long waiting time before VS actually starts the application when hitting F5 occurs in VS 2008 as well. The simple solution to that is to delete the .suo file. I don't know if VS 2010 uses .suo files, but at least it's something you can try.
This might not be the case, but I remember VS used to act like this when I had lots of breakpoints.

Checking if DWM/Aero is enabled, and having that code live in the same binary for 2000/XP/Vista/7

I know the title makes little sense, mostly because it's hard to explain in just one line. So here's the situation:
I have a program who's binary is targeted at Windows 2000 and newer. Now, I went ahead and added some code to check if the user is running under Vista/7, and if so then check if Aero/DWM is enabled. Based on this I'll disable some stuff that isn't relevant to that particular platform, and enable some other features. My main problem is that in order to call DwmIsCompositionEnabled from Visual C++ 2008 I have to add the dwmapi.lib file and compile against it. Running the binary in anything other than Vista or 7 gives the "Unable to locate component. The application failed to start because dwmapi.dll was not found" error. This, of course, is expected to happen since DWM is new and not available for older platforms.
My question is then: will it be possible for me to somehow manage to pull this off? One binary for all OS versions AND include that DWM check code? This program was written under Visual Studio 2008, Visual C++ using MFC.
Turns out I can just tell the linker to delayload the dwmapi.dll.
I'd like to thank ewanm89 because something he said sort of resonated and led me down the path to finding the actual answer.
The normal solution is to use LoadLibrary() and GetProcAddress(). Both can be done after your program started. But still +1 for the DelayLoad solution, which does the same for you behind the scenes.