3

I'm using Visual Studio 2010 SP1. I notice that I can add property sheets to a project but I cannot change the character set in those property sheets. Any property sheet I create is missing the 'Character Set' option.

Can anyone explain why I can't set the character set using a property sheet? Is there some list of forbidden properties that can't be set using a property sheet?

Thanks

loop
  • 3,460
  • 5
  • 34
  • 57
  • What do you mean by "can add property sheets"? How did you create the project? – Ajay Sep 10 '12 at 17:27
  • @Ajay I mean any project. It's not specific to a project or a solution. Although I can change the character set in the project I cannot change it in a project's property sheets. For example I want to switch several projects between character sets. Rather than having to do it for each individual project I am trying to do it through a property sheet. I'm sure this is possible through the Preprocessor Definitions section, but I would like to know why Character Set is missing. – loop Sep 10 '12 at 17:45
  • You question is still vague! My hint: Select multiple projects, select Multiple configurations, and set the option. Are you looking for _UNICODE/UNICODE ? – Ajay Sep 10 '12 at 17:56
  • @Ajay thanks I know about that. The thing is I have projects that must be compiled one way in one solution and another way in another solution. I thought if I had a property sheet I could save myself the trouble. I do know the workarounds but my question is why is the character set option missing from property sheets? It's in project properties but there's no option to inherit it from the sheet. I can't set the whole program optimization option in a property sheet either. I think it's a pretty clear question. I'm just curious. – loop Sep 10 '12 at 19:51
  • Still unclear, otherwise someone would have answered it by now, if not me. Post a screen-shot if you can. – Ajay Sep 11 '12 at 07:02
  • @Ajay, he's talking about the project property sheets that you edit from View / Property Manager. If you have many different projects that you want similar settings, you can create property sheets that you share among the projects. – criddell Sep 21 '12 at 03:36

1 Answers1

12

Ok I did some searching on my hard drive and found the answer.

Project Defaults, which Character Set is a part of, define which default MSBuild property sheets to inherit. Therefore when you choose Character Set in your project you are not changing preprocessor defines in your project file, and instead your project file will inherit a character set property sheet which changes those defines. If you do not choose a character set then no property sheet is inherited.

The Unicode and MBCS property sheets are located here:

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.MultiByteCharSupport.props
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.unicodesupport.props

The MBCS property sheet only adds _MBCS to the compiler's preprocessor defines (C/C++ Preprocessor Definitions). The Unicode property sheet only adds UNICODE and _UNICODE to both the compiler's preprocessor defines (C/C++ Preprocessor Definitions) and the resource compiler's defines (Resources Preprocessor Definitions). And that's it.

loop
  • 3,460
  • 5
  • 34
  • 57
  • Thanks for posting the solution. I'm having the exact same problem. – criddell Sep 21 '12 at 03:32
  • 1
    Thanks, this worked for VS2010. Unfortunately, we have moved to 2013 and now get an error, "error MSB8031: Building an MFC project for a non-Unicode character set is deprecated. You must change the project property to Unicode or download an additional library." even though we are building unicode by including Microsoft.Cpp.unicodesupport.props – Rob Prouse Sep 23 '13 at 15:41
  • 2
    Further to my last, this is happening because line 363 of C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets checks if you are using MBCS by looking at CharacterSet instead of looking to see if UNICODE is defined. I got around this by adding Unicode to the PropertyGroup of my base Property Sheet. – Rob Prouse Sep 23 '13 at 15:54
  • @RobProuse Where do I find the "base Property Sheet"? I'm getting this same error. I did full Solution search including external items for PropertyGroup, and couldn't find anything. Can I just add UNICODE to the preprocessor definitions? – Robert Oschler Oct 07 '14 at 01:32
  • 1
    @RobertOschler, you are probably not using Property Sheets. They are just *.props files that you use to include common settings between C++ projects. In your case, open up the .VSXPROJ file for your C++ project and add Unicode to the first property group. If you are not using property sheets, you can also try opening your project properties, go to General and set the Character Set to 'Use Unicode Characters Set'. One of the two should work. – Rob Prouse Oct 08 '14 at 02:36