C support in visual studio 2017 - c

Not C# or C++, but C. Is there any C support in Visual Studio?

Using the Visual Studio Installer if you click on your already installed version of Visual Studio (in the image I clicked on my VS 2017 Community).
Under Individual components --> Compilers, build tools and run-times you can check Clang/C2. Clang is a C compiler.
Answer: by default it appears not, but you can install the Clang component and it appears you will be able to.

Related

How do you syntax check and format code for C in Visual Studio 2019?

I'm used to programming Java in Intellij, where I can download extensions for Java syntax checker and Google style formatting. I'm wondering if there is an equivalent alternative in Visual Studio 2019 for C?

Programming in C in Visual Studio Community 2017 on Mac

I am taking C course and was required to work on VS community 2017. I've been trying to install it on my mac, and the process seem to go ok but I can't find an option to write in C, or to open a project with "Visual C".
It appears that Visual Studio for Mac does not support C or C++. Your options seem to be either Visual Studio Code or running Windows in a virtual machine on your Mac. You can check this post for details: https://social.msdn.microsoft.com/Forums/en-US/ef99e9f5-2a48-423b-b6c0-fa5617d7c63d/how-do-i-get-c-to-work-on-visual-studio-for-mac?forum=visualstudiogeneral

How to compile zlib into a DLL on Visual Studio 2017?

I have a hard time trying to do something I think is really simple (I must not be the first one to want to do that). I use Visual Studio 2017 on Windows 7 to do some C code, and I need inflate/deflate for zip.
I search a little, and I found zlib. It seem to be exactly what I search: free, cool copyright, no patent and extensively used and tested in other project.
So, I start to download the latest version (zip of 1.2.11) and here I go, trying to "simply" get the DLL.
However, the documentation state that in order to compile "zlib1.dll", I have to use "./contrib/vstudio/vc..", with ".." the right Visual Studio. But I have Visual Studio 2017 and there are only "vc9" to "vc14", "vc14" being Visual Studio 2015.
The doc say that I have to use Microsoft Visual C++ 2015, and indeed, when I force open with vs2017, I have integrity error.
So I try to install MVC++ 2015, but then it say that I can't install it because I already have something (VS2017) installed.
Is there really no way to achieve something so basic, or there is knowledge that I don't know?
Open source projects can be a challenge to build as their support tends to lag well behind the latest versions of Visual Studio. This is one reason why Visual Studio now supports cmake directly.
That said, the easiest way to build zlib for Windows is just use a NuGet package. I personally use zlib-msvc14-x86 or zlib-msvc14-x64 which are binary compatible with VS 2015 Update 3, VS 2017, and VS 2019. They also provide a static library instead of a DLL.

Trying to build Mozilla got this error when trying to open start-shell-msvc2015

I am trying to build Mozilla on Windows 7 64bit
I tried to run this start-shell-msvc2015.bat but got this error.
MozillaBuild Install Directory: C:\mozilla-build\
Visual C++ 2015 Directory: C:\Program Files (x86)\Microsoft Visual Studio 14.0\V
C\
Windows SDK Directory: C:\Program Files (x86)\Windows Kits\8.1\
Unable to call a suitable vcvars script. Exiting.
Press any key to continue . . .
I did everything according to their instructions
When in doubt, search Google for the error message. From the first result:
Hallvord R. M. Steen:
To anybody else who might have this problem: it's caused by choices made during installation, and the installer options were somewhat confusing. I don't remember the exact details, but I think the "Default" installation no longer gives you the required scripts - the "Default vs custom" section on https://msdn.microsoft.com/en-us/library/e2h7fzkw%28v=vs.140%29.aspx seems to confirm that you need to choose "Custom" during install and enable Visual C++ tools specifically.
Andrew Overholt: You're right, Hallvord. I went back to my VS2015 installation .exe download, clicked "Modify [the existing installation]" and picked "Common Tools for Visual C++ 2015" under "Programming Languages" > "Visual C++".
Also you'll need at least update 3 if you're using the VS2015 Community Edition. From that Mozilla dev docs page:
Once you’re up to date, download and install Visual Studio Community 2015 Update 3 from Microsoft. If you have an earlier version of Visual Studio, you'll need to upgrade; Firefox relies on C++ features that aren't supported in older versions of Visual Studio. Do not accept the default configuration. Instead, select **Programming Languages > Visual C++ > Common Tools for Visual C++ 2015.*
See also this question on Super User.
Furthermore, the MDN docs actually were updated with this info after that report, and indeed the current build instructions contain, in bold:
Be sure to install the "Common Tools for Visual C++ 2015", which requires a customized installation in Visual Studio 2015.
In the prerequisites section.
Also you'll need at least update 3 if you're using the VS2015 Community Edition. From that Mozilla dev docs page:
Once you’re up to date, download and install Visual Studio Community 2015 Update 3 from Microsoft. If you have an earlier version of Visual Studio, you'll need to upgrade; Firefox relies on C++ features that aren't supported in older versions of Visual Studio. Do not accept the default configuration. Instead, select Programming Languages > Visual C++ > Common Tools for Visual C++ 2015.

Using old code on new version of Visual Studio

I have a project which was started from 90s in C/C++. Therefore, it contains many old coding styles such as K&R-style function declaration, obsolete function, ...
The project works fine in Visual Studio 2008, but now I want to use it in the new version of Visual Studio (specifically VS 2010) because we have other projects in Visual Studio 2010/2012. I don't want to have too many versions of Visual Studio on my machine.
When I try to compile the old project, Visual Studio throws too many errors. I can fix all of them but I am scared to edit the source code and I want other people to be able to pen it in the old version of VS too. I want the project to remain backwards compatible with VS.
My question is how to use the old code in Visual Studio 2010/2012 without changing the code. Or if necessary how do I just fix a few lines of code, but make sure it won't cause an error if someone else opens that code in the older version of VS. Is there a way to tell newer Visual Studio versions to use older compiler flags or something like that?
Best option is IMHO to bite the bullet and install VS 2008 and VS 2012 both on your machine, and then use the V90 platform toolset within VS 2012 (that means, you can edit and debug in VS 2012, but VS will use the old VS 2008 compiler and debugger under the hood).
What you don't get that way, however, is backward compatibility concerning project files. VS 2012 is only backwards comptible to VS 2010, but not to VS 2008. If you need that really, you either have to maintain two versions of your project files (one for VS 2012 and one for VS 2008), or you must stick to VS 2008 as an IDE.

Resources