title: How to switch between build targets in Visual Studio Code?
body: <p>We are trying to move from Code::Blocks to Visual Studio Code for C/C++ development. The main reason is the way better code completion provided through IntelliSense. But the comparison of the two shall not be the topic here.</p>
  
  <p>In order to get our old projects compiling, we set up a makefile and tasks in Visual Studio Code. This works fine so far.</p>
  
  <p>Where things became complicated are different build targets. Let's say we have an example project, in which we need to compile two versions of our program, which are about 95% the same. So in Code::Blocks-times, we decided to keep everything in one project, but distinguish the different source code bits via defines and ifdef. So you select the proper build target, which appends the defines to the gcc call and the correct version of the two is built. To make things a little more complicated each version has also a debug and release target. So it is four build targets in total:</p>
  
  <ul>
  <li>Version 1 DEBUG, built with <code>-DVERSION1 -DDEBUG</code></li>
  <li>Version 1 RELEASE, built with <code>-DVERSION1 -DRELEASE</code></li>
  <li>Version 2 DEBUG, built with <code>-DVERSION2 -DDEBUG</code></li>
  <li>Version 2 RELEASE, built with <code>-DVERSION2 -DRELEASE</code></li>
  </ul>
  
  <p>So, our makefile, which we use in VS Code is setup that we can also select the build target and the proper versions are built. So far so good.</p>
  
  <p>Now the C/C++-Extension and IntelliSense come into play. They use clang to "compile" the code on the fly for auto completion and highlighting code sections, which are actually used. Because our <code>#define</code>s (VERSION1 or VERSION2) for the different versions are only provided to the gcc compiler in the makefile, clang does not know about them. Without knowing them, the code sections are grayed out (which is not that much of a deal), but also auto completion does not work for variables, which happen to be declared in such a section.</p>
  
  <p>Of course we can specify the defines in the <code>c_cpp_properties.json</code>and also make different build targets there. But this would mean, that we need to switch between build targets twice: first for the C/C++ extension and second for the makefile. I am pretty sure that people will forget one or the other and get frustrated.</p>
  
  <p>So long story short: Is there a way to switch build targets in Visual Studio Code, which affect both IntelliSense and the actual build?</p>