Bahadir_

Hi,

Due to the fantastic debugger and Intellisense technology Visual studio provides, I am now attempting to write my C code in VS.Net 2005.

I was able to compile C files, but the most annoying thing is that I cannot declare locals in "for" loops. Is there a way to configure the C compiler in VS.net 2005 to use C99 mode

Thanks,
Bahadir


Re: Visual C++ General VS 2005 Compile C in C99 mode?

Jonathan Caves - MSFT

The C compiler that ships as part Visual C++ does not fully support C-99.




Re: Visual C++ General VS 2005 Compile C in C99 mode?

Holger Grund

No, VC does not support C99 and probably won't for quite some time to come. There's support for a couple of C99 things (including for C++ mode), such as "long long", variadic macros, __restrict (which works like restrict), __FUNC* identifiers, __pragma (which is similar to _Pragma).

Of course, you might want to think about using C++ mode -- after all you don't have to use C++ features. But you get some things for free, e.g. stricter static type checks, initializers in loop and control constructs, declarations intermixed with statements etc.

-hg





Re: Visual C++ General VS 2005 Compile C in C99 mode?

Haitao Li

Hello Holger, could you explain a little bit about "__FUNC* identifiers" Did you mean __func__

Thanks.





Re: Visual C++ General VS 2005 Compile C in C99 mode?

Holger Grund

Yes, there's __FUNCDNAME__, __FUNCSIG__ and __FUNCTION__ in VC. The latter is similar to C99's __func__ but actually provides a bit more than that. While __func__ is a predefined identifier, __FUNCTION__ works much like a macro. For instance, you could create a wide character version of the function's name by using token pasting.

I believe, you could just #define __func__ __FUNCTION__ and get pretty much the C99 behavior. There might be some subtle differences (e.g. __FUNCTION__ could yield different pointers), but these seem to be rather academic.

-hg