title: Python extension: using different compiler flags for a C parts and C++ parts
body: <p>For my python extension, I have both C (from an embedded library) and C++ files and they are compiled and linked together. Only the C++ part interfaces with Python (via SWIG). This works both in windows with VS2015 and gcc under linux. However, with gcc, the C++ files need a different set of compiler flags (eg. -std=c++11, -Wno-reorder) than the C files, to avoid warnings concerning the improper flags in C. </p>
  
  <p>Is there a way in setuptools / distutils to change compiler flags for each file seperatly, eg. based on the file extension?</p>
  
  <p>I use already a custom build step from <a href="https://stackoverflow.com/a/36293331/3032680">https://stackoverflow.com/a/36293331/3032680</a>.</p>
  
  <h2>Update:</h2>
  
  <p>The main problem is, that <code>distutils.ccompiler</code> does not check the file extension for C or C++ and is running everything with $CC. Even defining CXXFLAGS does not help. I will stand the warnings, neither with <code>export</code> nor a definition using <code>os.eniviron</code> in the setup.py file.</p>
  
  <h2>Update 2:</h2>
  
  <p>On macOS with CLang 8.0.0 the situation gets worse: Trying to compile a .c file with -std=c++11 is not a warning but an error.</p>