Ethan Kharitonov
Ethan Kharitonov

Reputation: 251

Can Visual Studio 2019 Community edition enforce strict ANSI C compliance?

I am learning C and use VS 2019 community edition.

While learning C I do not want to use any C++ features accidentally, like declaring the for variable inside the for. E.g. right now this code compiles:

for (int i = 0; i < 100; ++i)
{
  ...
}

But it is not C, it is C++ and I wish the compiler to tell me that.

Is it possible?

Upvotes: 0

Views: 2360

Answers (1)

3CxEZiVlQ
3CxEZiVlQ

Reputation: 38508

Yes, Visual Studio enforces C compiler by file extension. If it meets .c, then it switches to using of C compiler. There is no option to say VS C compiler which C standard should be used. VS mostly conforms to C99, and doesn't fully support the latest C11. It is due to the fact that VS compiler is C++ compiler, and C programming language support is in the shadow.

Here is the better answer Is there any option to switch between C99 and C11 C standards in Visual Studio?

Upvotes: 2

Related Questions