evilmandarine
evilmandarine

Reputation: 4553

Which version of C is supported by VS2019 compiler?

How can I know which version of C is supported by the VS2019 compiler? I looked in the project C/C++ and Linker command lines and found no -std=Cxx flag. The following code compiles:

for (int i = index; i < nb_users - 1; i++) {
    users[i] = users[i + 1];
}

So I guess it's C99 according to this, but is there a way to check this somewhere in VS2019?

Upvotes: 4

Views: 1642

Answers (2)

chux
chux

Reputation: 153547

Which version of C is supported by VS2019 compiler?

At best, C 1989.


A compliant compiler to some C standard is identifiable via the values of __STDC__ __STDC_VERSION__.

#ifndef __STDC__
  printf("Does not ID itself as compliant to any C standard.\n");
#else
  printf("Compliant to some C standard\n");
  #ifndef __STDC_VERSION__
    printf("C 1989\n");
  #else 
    // Expected values of of 2019
    // 199409L
    // 199901L
    // 201112L
    // 201710L
    printf("C %ld\n", __STDC_VERSION__);
  #endif
#endif

I'd expect VS2019 to not identify itself compliant to any C standard or perhaps 1989.

__STDC__ Defined as 1 only when compiled as C and if the /Za compiler option is specified. Otherwise, undefined. Predefined macros


VS2019 not on this incomplete list of C compilers

Upvotes: 1

S.S. Anne
S.S. Anne

Reputation: 15576

VS2019 supports ANSI C90 plus a few other features from a few later standards that are required in C++.

For example, you can tell that C99 is not fully supported in MSVC with this code, which will fail to compile:

int foo(int n, char *s)
{
    char s2[n];
    strcpy(s2, s);
    return !strcmp(s, s2);
}

This specific feature (variable-length arrays) is not supported in MSVC, while the feature you mentioned (for loop initial declaration) is.

Upvotes: 3

Related Questions