Visual studio 2010 automatically switched to C++/CLI compiler - c++

I've been working to a C++/CLI project in the last few months.
Now I'm back to C++ but seems that VS 2010 has set to use C++/CLI compiler even for standard C++ projects.
I just created a new C++ empty project but when I compile the code, it seems using C++/CLI compiler.
Intellisense is disabled as well.
How can I restore the default C++ compiler to my project ?

Choose Project -> Properties from the menu bar. In the Project properties window, under Configuration Properties -> General, make sure that Common Language Runtime Support is set to No Common Language Runtime Support.

Related

convert Windows Forms Application in C++ to executable file

I am using VS10 C++ and try to convert Windows Forms Application project to executable file: this what I did
select project-> properties -> configuration properties -> C/C++
-> Code Generation -> Runtime library
then I select Multi-threaded Debug(/MTd)
when I built my project I got the following error
A Windows Forms application depends on classes from the .NET Framework Base Class Library. To develop a Windows desktop application in C++ that does NOT depend on .NET, you should use the project template for a Microsoft Foundation Classes (MFC) Application instead. This type of project will compile as a native .exe, instead of a .NET assembly. (By the way, not sure why you would still be using Visual Studio 2010 for C++ development, when the free VS 2015 Community Edition fully supports C++11 and many features of C++14. I do not yet recommend VS 2017 however, since it is still very buggy for C++ development.)
EDIT: In Visual Studio 2017, there is another option (which was not available in VS 2015). If you choose the Windows Desktop Application project template, you will get a project that depends on neither .NET (aka CLR support) nor MFC. I have never tried this approach, but on the surface, it looks very similar to MFC. Again, so far I have found VS 2017 for C++ to be very buggy, so you might have a better experience using MFC in VS 2015 instead.

Where are C/C++ Preprocessor settings in project properties UI in VS 2015 Community Edition?

With the hope of getting trained for C++ as a zero newbie, I was following directives to create a C++ dev environment on a PC equipped with Windows 10 and Visual Studio 2015 Community Edition.
I create a new C++ project on VS 2015 CE
When I right-click project properties, I cannot locate C/C++ > Preprocessor - it's just not there as can be seen from the screenshot.
So trying to figure out how on Earth I can add some custom preprocessor definitions here. :-(
Add at least one .cpp or .c file to your project (or, more generally, an item with ItemType "C/C++ Compiler").
A desired entry will appear in Project Property Pages (exactly where you expect it to be):
Configuration properties -> C/C++
There will be subentry "Preprocessor".
Alternatively, you may create a project of type
Visual C++ -> Win32 -> Win32 Console Application (or, more general, Win32 Project)
This type of projects already contains C++ files with some simple code.

General usage of c++ in visual studio

Is it possible to write a c++ code in Visual Studio without using c++.net?
I'm learning c++ at the moment - Using a book.
But I like the Visual Studio IDE but I don't know if it supports c++ or just c++.net.
I usually create a new (empty) directory and copy the source file(s) into that directory, then when creating the Visual Studio project using the name of the directory. To create a standard C++ console program, choose "... console application", then click on next, clear the check boxes below "empty project", and check "empty project". Once you're into the project, click on project, and "add existing item" to add the source file name(s).
If you want 64 bit mode, you'll need to right click on the project name, then properties, then configuration manager, then new, and select x64. It doesn't matter if you do this for debug or release build, it will set x64 mode for both build modes.
Yes, you can. Visual studio supports two types of C++ applications:
C++/CLI (also called managed C++) - Under Visual Studio project wizard, these kind of projects are grouped under CLR
Native C++ - Under Visual Studio project wizard, these are the projects grouped under Win32, MFC, ATL
Note, however, that you can always turn a project from native to managed and vice versa by going into the project properties and switching on/off the Common Language Runtime Support (/clr), so make sure this option is turned off (No CLR).
Also, be aware that different C++ compilers not always support the same C++ features (even if they are part of the standard), and some C++ compilers implement their own extensions to the language. In the case of Visual Studio, it defines Microsoft Extensions to C and C++ that can be turned off (Za) to be more ANSI compliant.
Visual Studio is actually notoriously late when it comes to supporting the C++ standard. Even now, some C++11 features are not part of the latest Visual Studio so keep this in mind when wondering why something you read in a book does not work in Visual C++.
One last note. Avoid using ATL and MFC if you try to be cross-platform compatible. Even if you don't want to be cross-platform compatible, ATL and MFC are only supported by Visual C++ and using them will lock you to using Visual Studio. Now with the Community Edition, both ATL/MFC are available for free if you are an independent developer or a small company, while historically, ATL/MFC were paid-version only as they are not part of Visual Studio Express editions.
It depends on which variant of Visual Studio you're using. If Express edition you want "for Desktop" in order to do ordinary standard C++. With full Visual Studio there's no problem.

Native C++ programs in Visual Studio

I'm confused in my understanding of the relationship between Visual Studio and .NET. I want to write a C++ application, but not a ".NET C++" application. By this, I mean that my understanding is that everything built in .NET land gets compiled to a CLI-compatible intermediary code (just like "JVM" languages like Java and Groovy compile to the same bytecode).
But I don't want my app compiled to an intermediary bytecode...I want it compiled down to raw binary!
Does Visual Studio do this? Or is .NET forced down my throat the minute I choose VS as my C++ IDE? If so, whats a "raw C++" alternative to VS?
Thanks in advance!
Visual Studio is an IDE, which is orthogonal to any specific language or compiler.
Visual C++ is a compiler that supports the C, C++, and C++/CLI languages.
In Visual Studio, create a Visual C++ project from one of the 'Win32' (as opposed to 'CLR') project templates and your program won't have any .NET dependency.
there is that /clr compiler switch when compiling a c++ app. Without it, you will get a pure native binary and cannot use any. NET specific features within your code.
By selecting a project template or by setting the corresponding project property, VS will automatically choose if the switch is on or off.
Visual Studio still supports 100% native C++ applications as will as managed applications. When creating a new app just choose the "Win32 Console Application" to create a native application. For existing applications you can change / verify by doing the following
Right Click on the project and select "Properties"
Navigate to Configuration Properties -> C/C++
Make sure that "Common Language Runtime Support" is set to "No Common Language Runtime Support"

VS 2008 C++ how to make a project without .net dependency

I am writing a plain vanilla c++ console app using VS 2008. When I create the project, the IDE gives me a choice of .net versions. There is no option for 'none'. When I look at the project properties page, the Targeted Framework has whatever value I chose and is greyed out.
When I try and run the app on a windows machine without the clr, it gives me a setup error and quits.
There is nothing in my code that has anything to do with .net. How can I escape the clutches of .net and the clr?
How are you creating the project? If I start Visual Studio 2008 and go File / New / Project... / Other languages / Visual C++ / Win32 / Win32 Console Application, I get a plain old C++ project with no .net dependency.
Make sure that you chose the "Win32 Console Application" project type. This will give you a C++ only project. Most of the other console options will bind the project to .Net.
Just choose Win32 Console Application. The drop down at the top of the window is irrelevant.
alt text http://img15.imageshack.us/img15/2029/screenmzi.jpg
The problem (based on your comment under the question) has nothing to do with .NET.
The problem is most likely how you link to the C runtime library.
Visual Studio defaults to using the dynamically linked (dll) version, which means that dll has to be present on the target machine.
The simple fix is to change your project to use the statically linked version.
Under project properties -> C/C++ -> Code Generation, set Runtime Library to Multi-Threaded or Multi-Threaded Debug (but not Multi-Threaded (debug) DLL).
Alternatively, you have to deploy the runtime dll along with your program.
Also if you right click the project in the solution explorer and go to Properties->Configuration Properties->General
You should be satisfied to see that the "Common language support" field should be set to "No common language support" if you followed the above advice i.e. compiling with no clr !
Use Dependency Walker to find out which DLLs are needed to yours program. May be problem is not with .NET, and with Runtime or ATL libraries. Did you used static linkage?