I understand the C++ and C syntax, but im a little unsure how i am supposed to code in the VS2010 environment, when i create a project i am presented with folders such as headers and sources.
What c++ code goes into which folder?
Also, how would it work for C?
.h files go into headers, .cpp files go into sources.
Project->Add Class will do the work for you
I agree that Visual Studio can be a bit overwhelming if you're used to code C/C++ using a simple text editor and calling the compiler via the command line.
Decide for yourself how you want to continue with Visual Studio.
If you want to create simple C/C++ applications (consisting of only 1 or 2 source files), just create an empty project and choose "Add Item" to add a source (.c, .cpp) or include (.h) file.
If you want to evolve to more complex applications with e.g. using the MFC libraries, .Net, WPF, ... learn how to use the Visual Studio wizards. These wizards can set up a complete environment for you so you only have to fill in your business logic. Consider reading a Visual Studio 2010 tutorial to get you started.
Related
InstallShield must be the crappiest "industry standard" application in existence, for reasons too numerous to enumerate here. However, one of those deficiencies is something I'd like to be able to fix, and with my first foray into writing an extension for Visual Studio (currently using 2015 version).
InstallShield has created a .isproj type, to allow integration with Visual Studio. This allows a developer to create an installer that references the output of a project as the files to include in the installer (rather than having to manually select individual files to include). This works well enough as long as the .isproj is being built in Visual Studio, and in a solution that references the project for which you need the output.
However, I also have an automated build for my installer projects, that we run on a build server using MSBuild. When attempting to build this way, we were getting completely opaque error messages indicating that the project output references above couldn't be resolved.
As with all InstallShield errors, Googling for answers turned up nothing except for multitudes of other people having the same problem. So I decided to dig into the plain text of the .isproj to see what I could find.
As it turns out, the .isproj type is a just a regular MSBuild script, and it even has lines commented out that explain options that can be added to the project; one of those things that can be added is an ItemGroup containing ProjectReference nodes. Manually adding the nodes helped solve the problem. Command-line build now works.
However, I am dissatisfied with a) having to manually type this stuff in, b) having no visual representation of what projects are being referenced, and c) not finding out about a problem until the build fails. So, I would like to be able to extend Visual Studio to help me with this. Here's what I'd like to do:
1) Add a "References" node to the project in Solution Explorer that acts like the References node for any normal .csproj.
2) Restrict the available References to other projects in the the current solution.
3) Visually represent a project with missing references (e.g. by underlining the project name with a colored squiggly, as with errors/warnings), and potentially failing the build if missing (depending on whether I want to treat it as an error or a warning; TBD).
To these ends, I've downloaded MPF for Projects - Visual Studio 2013, which provides an SDK for creating a new project type.
However, before digging too deeply, I need to know if it's even possible to EXTEND an existing project type, as described above, as I obviously don't have InstallShield source code. Also, any links or guidance as to a starting point for doing so would be greatly appreciated.
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.
Think this will be rather simple but somehow I could not find a reference saying about this.
In the MSVC Include directories, there is an Additional Include Directories setting. The setting reads like this
..\Project1; %(AdditionalIncludeDirectories)
Understand the first part is the path for the program to search for additional program header includes. What about " %(AdditionalIncludeDirectories) " ? what does it mean?
It does not seem to be a macro which I understand is headed by "$" eg $MACRO
Thanks
Answer
In the documentation for Working with Project Properties there is a section on "item macros":
Item macros
Has the syntax %(name). For a file, an item macro applies only to that fileāfor example, you can use %(AdditionalIncludeDirectories) to specify include directories that apply only to a particular file. This kind of item macro corresponds to an ItemGroup metadata in MSBuild. When it's used in the context of a project configuration, an item macro applies to all files of a certain type. For example, the C/C++ Preprocessor Definitions configuration property can take a %(PreprocessorDefinitions) item macro that applies to all .cpp files in the project. This kind of item macro corresponds to an ItemDefinitionGroup metadata in MSBuild. For more information, see Item Definitions.
Discussion
I had exactly the same problem in a project I am taking over from a former developer : his Additional Include Directories are C:\Users\t-tshmit\Downloads\DirectXTK;$(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories)
And oddly the %(AdditionalIncludeDirectories) element is not included in the edit box
Looking around the web I could not find much on this, but it is clearly a pattern in use, for example the screenshot used in http://www.steptools.com/support/stdev_docs/help/settings_vc10.html may contain the %(AdditionalIncludeDirectories) element.
The documentation for both the Additional Include Directories compiler options and the AdditionalIncludeDirectories VCCL Compiler Tool property contain no mention of this %(NAME) pattern.
https://learn.microsoft.com/en-us/cpp/build/reference/common-macros-for-build-commands-and-properties?view=vs-2019
They are called "item metadata macros."
The build system for C++ was significantly changed between Visual
Studio 2008 and Visual Studio 2010. Many macros used in earlier
project types have been changed to new ones. These macros are no
longer used or have been replaced by one or more equivalent properties
or item metadata macro (%(name)) values. Macros that are marked
"migrated" can be updated by the project migration tool. If the
project that contains the macro is migrated from Visual Studio 2008 or
earlier to Visual Studio 2010, Visual Studio converts the macro to the
equivalent current macro. Later versions of Visual Studio can't
convert projects from Visual Studio 2008 and earlier to the new
project type. You must convert these projects in two steps; first
convert them to Visual Studio 2010, and then convert the result to
your newer version of Visual Studio. For more information, see
Overview of potential upgrade issues.
I'm a long time Eclipse user trying to learn to Visual Studio. I know that Eclipse had Code Templates that would allow you to build classes with certain comments and formatting already added for a class.
For example:
Auto placing the copyright for the code at the top of the file
Who created the file
Predefined Comments,
etc...
Does Visual Studio 2005 have any functionality like this?
It depends. Visual Studio has a built-in code snippets manager that lets you do things like this to at least a degree (i.e., if you insert a code snippet, it'll be formatted as the snippet specifies, but if you write the same code manually, it won't). Also note that there are limitations on the languages with which you can use code snippets.
Outside of that, most of the major add-ins for VS (e.g., Visual Assist-X) provide their own ability to store and insert bits of code, formatted as you specify. Most of these provide at least some features missing from the built-in snippets manager such as working with other languages or being easier to access (along with quite a few other things -- IMO, VS borders on completely unusable without VA-X).
I would recommend looking at item and project templates in Visual Studio, which sound like what you're looking for. But, in your particular case (C++ development), it doesn't look like this is available to you.
The following MSDN article refers to VS templates, and mentions that for Visual C++ projects, that the template architecture isn't supported. Instead, there's information on creating custom wizards for your project and classes, which may give you the flexibility that you need. Sounds like it'll do what you want it to do, but it's much more work than it would be if you could use an item template for including basic comment structure for a default class file.
http://msdn.microsoft.com/en-us/library/6db0hwky%28VS.80%29.aspx
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.