all groups > visual studio .net general > february 2005 >
You're in the

visual studio .net general

group:

bool unrecognized in ".c" files


bool unrecognized in ".c" files Stirling via DotNetMonster.com
2/6/2005 4:35:39 AM
visual studio .net general:
Does anyone know why ".c" files in .NET 2003 do not understand the "bool"
data type? A ".c" file with a "bool" declaration will not compile, but I
can rename the ".c" file to ".cpp" and it will compile.

This is only a problem on new projects created under .NET 2003. I was
converting a large group of projects from Visual C++ 6.0 to the .NET 2003
Visual C++ (ie, .dsp files to .vcproj files), and those converted projects
have no problem with bool in ".c" files.

I've tried Console apps as well as Window apps, but there is no difference.

I've created a new project which duplicates one of my converted projects
(ie, same source files, etc), and have validated that the settings under
the "properties" tab match exactly, adn the new project will not understand
"bool", while the converted project is file.

I presume there is some setting I'm missing, but I haven't been able to
find it. Any help would be greatly appreciated.

Thanks.

--
Re: bool unrecognized in ".c" files Bo Persson
2/6/2005 10:34:53 AM

"Stirling via DotNetMonster.com" <forum@DotNetMonster.com> skrev i
meddelandet news:0f05b9692e0f4bc787d3f5688ae5843d@DotNetMonster.com...
[quoted text, click to view]

There is a project setting under "C/C++", "Advanced" where you can
choose "Compile as C" or "Compile as C++". This overrides the use of .c
and .cpp extensions to determine the language.

Standard C++ has bool, while the C language didn't get that until the
C99 revision. MSC is still mostly C89.


Bo Persson

Re: bool unrecognized in ".c" files Stirling via DotNetMonster.com
2/6/2005 4:00:49 PM
Thanks for the reply.

Both projects are set to "compile as c++" and it still didn't work.

However, I have figured it out. While the project settings are "compile as
C++", sometimes when you load in a new ".c" file, the file doesn't inherit
the project settings and it will override the project setting and set its'
own property to "compile as c" - that's pretty annoying, especially since
it only happens most of the time, not all of the time.

Another neat "feature" is if you close out of the project/solution,
sometimes when you restart the project/solution the ".c" file which which
had overridden the project settings will inherit the settings at restart
and will compile - again, not always, just sometimes.

I love consistency.

Anyway, thanks for the reply, when I restarted to the project to verify my
settings and noticed everything "all of a sudden" starting compiling, it
made me realize that maybe each individual file had its own properties
setting which I had not thought of before.

Stirling

--
AddThis Social Bookmark Button