Thread: Compiling with Clang on Visual Studio

  1. #1
    Registered User
    Join Date
    Mar 2015
    Posts
    384

    Compiling with Clang on Visual Studio

    I downloaded Visual Studio Community 2015 with Update 1 (i.e. Clang with Microsoft CodeGen), and installed Clang in Visual Studio, but I don't know how to get Visual Studio to compile my code using with Clang instead of its built-in compiler. What do I do?

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    In general, you need to go to project properties => configuration properties => Platform toolset. Choose the option with clang in it.

    Read this very carefully: Clang with Microsoft CodeGen in VS 2015 Update 1 - Visual C++ Team Blog - Site Home - MSDN Blogs

  3. #3
    Registered User
    Join Date
    Mar 2015
    Posts
    384
    Thanks. I'll take a look at that.

    Edit: While I was reading that, I came across a part that says that with the Clang Toolset enabled, exception handling gets turned off by default. So how do I turn it on?
    Last edited by Osman Zakir; 01-29-2016 at 05:25 PM.

  4. #4
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    There should be an option "Enable C++ Exceptions" under C/C++ in configuration settings. Please get familiar with project properties.
    Last edited by whiteflags; 01-29-2016 at 06:45 PM.

  5. #5
    Registered User
    Join Date
    Mar 2015
    Posts
    384
    It seems like I don't need to do anything, really; on mine, exceptions are turned on by default.

    I've used Clang and GCC before, even on the command-line, so I know that command-line options for both of those are written suffixed with a hyphen. But I heard that I'll have to manually change the command-line option configuration in VS, even though I seem to be able to compile my code pretty well in VS with Clang turned on. What do you think is going on? It seems like that page about Clang with Microsoft CodeGen being added to VS is kind of old? Since a lot of the problems/known bugs it talks about seem to already have been fixed, which may or may not include the need to manually change the command-line option configuration to be able to correctly compile C/C++ code in VS.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling C with a Makefile in Visual Studio
    By cian in forum C Programming
    Replies: 12
    Last Post: 10-20-2013, 02:05 AM
  2. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 04:25 AM
  3. Beginner question about compiling and visual studio
    By GibsMe in forum C Programming
    Replies: 4
    Last Post: 09-13-2009, 03:36 AM
  4. Compiling Error in Visual Studio 2005
    By JeroG in forum C++ Programming
    Replies: 4
    Last Post: 02-06-2009, 09:26 AM
  5. Compiling from DOS Prompt using Visual Studio Express 2005
    By The SharK in forum C++ Programming
    Replies: 8
    Last Post: 06-13-2006, 01:24 AM