Can't get CPPCheck VS add-in to ignore a file - c++

I am using CPPCheck with the visual studio plugin. In the settings menu for it there is a an option 'Edit Global Suppressions'. What I would like to do is use the option 'File excluded from check (C# regex)' to stop cppcheck from looking through a large single-file header-only test framework file I am using called Catch. When I run 'check current project with cppcheck' I have to wade through a large number of messages from code I didn't write, nor am interested in fixing.
I am not good with regex but I have tried a lot of combinations to get it to ignore this file without success. Is there an obvious regex statement I haven't come across or is this feature not working. I didn't see an issue in the VS plugin repo so I'm willing to bet its just me.
P.S. The file is stored in the usual place for a visual studio C++ project:
D:\Libraries\Documents\Visual Studio 2015\Projects\ReliableControls\ReliableControls\catch.hpp.
Here is a short list of entries I've tried... that I can remember. (ReliableControls is the name of the project).
^ReliableControls\catch.hpp$
^ReliableControls\catch\.hpp$
^catch.hpp$
^catch\.hpp$
EDIT
Here is the list of the defaults in the exclude file window. I've tried following similar patterns.
^moc_.*\.cpp$
^qrc_.*\.cpp$
^ui_.*\.h$

Related

Can I make Visual Studio show a notification or alert when I open a particular project or solution

I would like to perform an action upon opening a particular Visual Studio 15/17/19 solution.
I need to inform anyone who is about to work on the project that there are important notes (included in the project) that they should read first. Ideally it would be a pop up so as to be very obvious.
When googling I can only find solutions that involve Visual Studio extensions but I need something that does not rely on anyone else doing anything (e.g. installing the extension) - it needs to be something dependent only on the project itself.
I'm hoping for something that I can add in the .sln or .scproj file that VS will see when it loads the solution and take action, but anything that achieves the same purpose would be good.
I'd be grateful if someone is able to let me know how I can achieve this.
You've got an extension called Solution Open Pop Up supported on many versions of Visual Studio.
In the Overview tab there is a Features section where you can see a short example of how to use it. From the extension's website:
If a file called SolutionOpenPopUp.txt and/or ReadMe.txt exists in the root folder of the solution, the contents are shown in a pop-up when the solution is open.

Highlight selected C/C++ file at the right place in other project in the same solution

I'm trying to understand a framework in C++, Visual studio by studying this framework's examples. All of such examples and framework are projects, and grouped in a solution in Visual Studio 2012. And each time, while reading an examples, I want to go into some classes the framework for more understanding and see where such classes located in filters in framework.
I searched in stackoverflow for highlighting filter in Visual Studio and I got two answers: link 1 and link2.
But my problem is I followed instructions in these two links, and they helped me highlight selected files, but they only highlight the selected file in the filter "External Dependencies". It do not highlight the source file at the right places, which is in other projects but in the same solution.
There's any way to do it?
If you would like to examine the declaration or definition (implementation) of a particular type you can right click on the name and select "Go To Declaration" or "Go To Definition". If they are available Visual Studio will open the appropriate file and take you directly to the item you want to examine. It may display multiple choices (i.e. there are a few forward declarations of a type) that will allow you to select which one to view. As long as the source for the framework is in a project loaded in the solution this should be more than sufficient for your needs. If the framework doesn't have a Visual Studio project it's quite easy to create one and add the source files to it. Features like Intellisense, class browsing, etc. will be available for the framework and the project doesn't even have to build without errors.

C++ parsing a text file that is located online

Information about what I want to do:
-read in a few integer variables from a text file that will be located on a dropbox public folder.
-the variables will be used to trigger some if statements thus controlling my application remotely if I need to have it do something ( I would just save the variable I need to that text file and my program with would read from it every 5 seconds would see it and perform the required actions).
-this is a console application which is being built and compiled in visual studio 2010 on windows 7. The software will also be running on a win7 computer.
I need help with:
I already have read on using a library called libcurl. The problem is that I do not know how to link this library with my project in vs2010. Detailed instructions on how to do this on vs 2010 would be very helpful.
OR
if you can think of a better and easier way to accomplish what I need done, offer some advice and direction
It sounds like you're a novice, is that correct? If not then apologies for stating the obvious.
To use your compiled DLL in your application you need to 'add a reference' to it. You can do this by adding what is called a binary reference, where you simply tell visual studio where to find the dll. Or you can add a project reference if the project which is producing the dll is within the same solution. The best approach is to use something called nuget. It's a visual studio extension which automates the adding of binary references available from a public repository.
I have just done a search for libcurl on nuget.org and drew a blank. As I am unfamiliar with this library you may have better luck finding a nuget package as you will be a le to search using better terms that I did (curl and libcurl)
Whatever approach you take, just right-click on the project in which you want to use libcurl within the solution explorer and you should find an add reference option in the menu.

Compressing js and css using Team Foundation Server 2010

I have been banging my head on a brick wall that seems to be easily worked around for everyone except me.
I want to setup css and js compression using a standard build on Team Foundation Server 2010. Below is what I've tried so far and failed. I am looking for a magic helping hand to guide me into setting this up the way professionals (SO is full of em) believe it should.
http://yuicompressor.codeplex.com/releases/view/46679 (dowload demo using post-build events)
This method looked promising as it did exactly as promised when you build your project in Visual Studio.
My msbuild Post-build command:
$(MSBuildBinPath)\msbuild.exe
"$(ProjectDir)MSBuild\MSBuildSettings.xml"
/p:CssOutputFile="$(TargetDir)..\Content\StylesSheetFinal.css"
/p:JavaScriptOutputFile="$(TargetDir)..\Scripts\JavaScriptFinal.js"
However when the build is run by TFS I get a lot of errors like these:
D:\Builds\3\CKB 2010_Build_CP\Sources\CKB
2010\My.Name.Space\MSBuild\MSBuildSettings.xml (61): Failed
to save the compressed text into the output file [D:\Builds\3\CKB
2010_Build_CP\Binaries..\Content\StylesSheetFinal.css]. Please check
the path/file name and make sure the file isn't magically locked,
read-only, etc..
So clearly the problem is the syntax in the Post-build command that is wrong. But I can't figure out how to make it work for both local and TSF builds.
Update 2011-08-17
As noted by Edward Thompson, I've tried adding a backslash to the path:
$(MSBuildBinPath)\msbuild.exe
"$(ProjectDir)MSBuild\MSBuildSettings.xml"
/p:CssOutputFile="$(TargetDir)\..\Content\styles.min.css"
/p:JavaScriptOutputFile="$(TargetDir)\..\Scripts\scripts.min.js"
And the result is this:
Failed to save the compressed text into the output file
[D:\Builds\3\CKB 2010_Build_CP\Binaries\\..\Content\styles.min.css].
Please check the path/file name and make sure the file isn't magically
locked, read-only, etc..
The problem is the difference in values with which TFS and Visual Studio run the msbuild command.
These are the steps I have taken to get proper YuiCompressor integration with Visual Studio 2010 and Team Foundation Server 2010.
In your desired project add a folder named 'MSBuild'
In this folder you should extract the files you download from the YuiCompressor project on CodePlex
Set the properties of these files like this:
Now open the MSBuildSettings.xml file and edit it according to the scripts and css files you want to have compressed. I have uploaded mine on pastebin since pasting it here caused problems with the editor.
Add the following postbuild event to your project. Note that the paths can differ for your environment.
IF "$(BuildingInsideVisualStudio)"=="" $(MSBuildBinPath)\msbuild.exe
"$(ProjectDir)MSBuild\MSBuildSettings.xml"
/p:CssOutputFile="$(TargetDir)_PublishedWebsites\$(ProjectName)\Content\styles.min.css"
/p:JavaScriptOutputFile="$(TargetDir)_PublishedWebsites\$(ProjectName)\Scripts\scripts.min.js"
IF "$(BuildingInsideVisualStudio)"=="true"
$(MSBuildBinPath)\msbuild.exe
"$(ProjectDir)MSBuild\MSBuildSettings.xml"
/p:CssOutputFile="$(TargetDir)..\Content\styles.min.css"
/p:JavaScriptOutputFile="$(TargetDir)..\Scripts\scripts.min.js"
Build the project and see if the files where created as expected.
Perform a check-in and watch the tfs build create the compressed files for you.
For debugging the tfs build, you'll find the logs in the msbuild log which is linked inside the normal tfsbuild log.
I hope this helps someone out there. I couldn't find a decent guide anywhere so now there is one here! If you have other suggestions, feel free to add them or post them in the comments.
One thing that sticks out at me is that you're using $(TargetDir)..\ - which expands to \Binaries..\. I suspect that you don't have a Binaries.. directory, and that this is supposed to be \$(TargetDir)\..\. (Ie, the parent of the Binaries directory.)

Import Existing C++ Source Code into Visual Studio

I am trying to import an existing c++ application's source into visual studio to take advantage of some specific MS tools. However, after searching online and playing with visual studio, I cannot seem to find an easy way to import existing c++ source code into visual studio and keep it structurally intact.
The import capacity I did find flattens out the directories and puts them all into one project. Am I missing something?
(This is all unmanaged C++, and contains specific builds for win/unix)
With no project/solution loaded, in Visual Studio 2005 I see this menu item:
File > New Project From Existing Code...
After following the wizard, my problem is solved!
Switching the "Show All Files" button shows the complete hierarchy with all directories and files within.
If the New Project From Existing Code... option isn't available, you'll need to add it in Tools > Customize...
I am not aware of any general solution under the constraints given - specifically having to create many projects from a source tree.
The best option I see is actually creating the project files by some script.
Creating a single project manually (create empty project, then add the files),
Configure it as close as possible as desired (i.e. with precompiled headers, build configurations, etc.)
Use the .vcproj created as skeleton for the project files to be created
A very simple method would file list, project name etc. with "strange tokens", and fill them in with your generator. If you want to be the good guy, you can of course use some XML handling library.
Our experience: We actually don't store the .vcproj and .sln in the repository (git) anymore, but a python script that re-genrates them from the source tree, together with VS 2008 "property sheet templates" (or whatever they are called). This helps a lot making general adjustments.
The project generation script contains information about all the projects specialties (e.g. do they use MFC/ATL, will it create DLL or an EXE, files to exclude).
In addition, this script also contains dependencies, which feeds the actual build script.
This works quite well, the problems are minor: python requried in build systems, not forgetting to re-gen the project files, me having to learn some python to make adjustments to some projects.
#Michael Burr "How complex are the python scripts and whatever supporting 'templates' you might need?"
I honestly can't tell, since I gave the task to another dev (who picked python). The original task was to provide a build script, as the VS2008 solution build was not good enough for our needs, and the old batch file didn't support parallelization. .vcproj generation was added later. As I understand his script generates the .vcproj and .sln files from scratch, but pulls in all the settings from separate property sheets.
Pros:
Adding new configurations on the fly. Some of the projects already had six configurations, and planning for unicode support meant considering doubling them for a while. Some awkward tools still build as MBCS, so some libs do have 8 configs now. Configuring that from hand is a pain, now it just doesn't bother me anymore.
Global changes, e.g. moving around relative project paths, the folder for temp files and for final binaries until we found a solution we were happy with
Build Stability. Merging VC6 project files was a notable source of errors for various reasons, and VC9 project files didn't look better. Now things seem isolated better: compile/link settings in the property sheets, file handling in the script. Also, the script mostly lists variations from our default, ending up easier to read than a project file.
Generally: I don't see a big benefit when your projects are already set up, they are rather stable, and you don't have real issues. However, when moving into the unknown (for us: mostly VC6 -> VC9 and Unicode builds), the flexibility reduced the risk of experiments greatly.
Create a new empty solution and add your source code to it.
For example,
File>New>Project...
Visual C++>Win32>Win32 Console Application
Application Settings>
- Uncheck "Precompiled Header"
- Check "Empty Project"
Project is then created. To add existing code:
Project>Add Existing Item...>
- Select file(s) to add
Recompile, done!
In the "Solution Explorer" you can click on the "Show All Files" button to have Visual Studio display the files as they exist on the file system (directories and all).
In my opinion this is an imperfect workaround, but I believe it's the best available. I'm unaware of a plug-in, macro or other tool that'll import a directory into an actual project with folders that mirror the file system's.
I know this question is already marked correct, but I was able to import existing code into a project with Visual Studio 2008 by doing "File" -> "New Project from existing code". The directory structure of my code was retained.
You can always switch view from project menu
For eg. Project->Show All Files
The above will display the files in unformated raw file system order
Not sure of older versions but it works on VS 2010
I understand you, I have the same problem: many .cpp and .h files organized in many folders and subfolders with include paths written for this folder structure. The only way you can do to import this folder structure together with the source files is to use "Show All Files" and then right-click on folders and select "Import in Project". This works for me when I am using C-Sharp projects. But it does not work for my C++ Projects. I am still searching for a solution...