Fixed: CLANGCOMPILE : error : invalid argument ‘-std=c++11’ not allowed with ‘C/ObjC’

By | November 7, 2019 | 0 Comment
Category: C/C++

Issue:

I am compiling a solution with C++ and C files together. If I compile only C files, it worked but as soon as I added C++ files, it was complaining about C++11 features. Based on online forums, when I added “-std=c++11” under Visual Studio Project > Properties > Configuration Properties > C/C++ > Command Line > Additional Options > added “-std=c++11” within the textbox and the following error showed up.

CLANGCOMPILE : error : invalid argument ‘-std=c++11’ not allowed with ‘C/ObjC’

Root Cause (Probably as I am not a C/C++ developer): Added options are used for all the C and C++ files. For C++ file, it is fine but for C files, it causes an issue.

Solution: Go to Visual Studio Project > Properties > Configuration Properties > C/C++ > > Language> Select “C Language Standard” = “C11 (-std=c11)” and select “C++ Language Standard” = “C++11 (-std=c++11)”. This way, Visual Studio will automatically pick up correct standard for respective files.


About Vishal Monpara

Vishal Monpara is a full stack Solution Developer/Architect with 13 years of experience primarily using Microsoft stack. He is currently working in Retail industry and moving 1's and 0's from geographically dispersed hard disks to geographically dispersed user leveraging geographically dispersed team members.