Home > Software design >  C version in .vcxproj files
C version in .vcxproj files

Time:09-29

Is this possible to fetch project's standard of C language from .vcxproj files without opening Visual Studio and manually checking it?

CodePudding user response:

Search the Label <LanguageStandard> in .vcxproj.

Simple test in C :

fstream file;
file.open(path, ios::in );
if (!file.is_open())
{
    cout << -1 << endl;
    return;
}

string temp;
string result;
while (getline(file, temp))
{     
    istringstream ss(temp);
    while (ss >> result)
    {
        if(result.find("<LanguageStandard>") != std::string::npos) std::cout<<result<<std::endl;
    }
   
}

Use python for example:

f=open('FilePath')
lines=f.readlines()
for lines in lines:
    if  "<LanguageStandard>" in lines:
        print(lines)

CodePudding user response:

I can not add comment. So I post answer here.

In Visual Studio C project, LanguageStandard will not appear if the language standard has not been changed (Default C 14). After specifying the language explicitly and rebuilding the project, You will find LanguageStandard in the .vcxproj file.

There should be similar code samples in C#.Good luck!

  • Related