Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2010 C and C++ - enforce ANSI compliance for Linux/gcc compatibility?

I'm taking a class in which I'm required to write some C++ apps for Linux. I really, really dislike the dev tools available under Linux, but I love VS2010.

Is there any sort of compiler switch which will enforce ANSI or gcc compatibility in VC++? Or can I swap the compiler out for gcc and still use the VS environment?

like image 696
3Dave Avatar asked Feb 20 '11 21:02

3Dave


People also ask

How do I change from C++ to C in Visual Studio?

In Visual Studio You can set compiler options for each project in its Visual Studio Property Pages dialog box. In the left pane, select Configuration Properties, C/C++ and then choose the compiler option category.

What is the latest enable STD C ++?

Select the Configuration Properties > C/C++ > Language property page. In C++ Language Standard (or for C, C Language Standard), choose the language standard to support from the dropdown control, then choose OK or Apply to save your changes.

What is_ msc_ ver?

_MSC_VER Defined as an integer literal that encodes the major and minor number elements of the compiler's version number. The major number is the first element of the period-delimited version number and the minor number is the second element. For example, if the version number of the Microsoft C/C++ compiler is 17.00.

What version of C++ is Visual Studio using?

The compiler now supports the /std:c++20 compiler mode. Previously, C++20 features were available only in /std:c++latest mode in Visual Studio 2019. Features that originally required /std:c++latest mode now work in /std:c++20 mode or later in the latest versions of Visual Studio.


2 Answers

You can disable Microsoft extensions to the ANSI C and ANSI C++ standards by specifying the /Za flag, which will make the compiler emit errors if you use non-standard C and C++ features.

http://msdn.microsoft.com/en-us/library/0k0w269d(v=VS.100).aspx

However, this doesn't preclude you from using platform specific headers.

like image 68
逆さま Avatar answered Oct 18 '22 01:10

逆さま


This blog post seems to discuss something similar to what you're after.

I can't seem to find better info than this MSDN document regarding VS2010 ANSI compatibility.

Some alternatives to VS2010 include MonoDevelop - which supports C#, VB.Net, C/C++.

There's also Eclipse IDE for C/C++ Dev.

This stackoverflow question may also be of use.

like image 42
cofiem Avatar answered Oct 18 '22 03:10

cofiem