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

Issue

I am compiling a solution with C++ and C files together. If I compiled 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'

Probable Root Cause

(Note: 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.

Share

0 comments

Your email address will not be published. Required fields are marked *