Skip to content

Use compiler's default standard version(s) when probing the compiler, if none was specified. #5579

Description

@ghuser404

By default, gcc is using gnu C/C++ standard (gnu99, etc.). This means that __STRICT_ANSI__ is not defined. However, cpptools will always define __STRICT_ANSI__, unless otherwise specified with cStandard (specifying "cStandard": "gnu99" will correctly result in __STRICT_ANSI__ not being defined).

Consider the setup below. IntelliSense shows "__STRICT_ANSI__ defined", but running this program, it prints "__STRICT_ANSI__ not defined".

main.c

#include <stdio.h>

int main()
{
#ifdef __STRICT_ANSI__
    printf("__STRICT_ANSI__ defined\n");
#else
    printf("__STRICT_ANSI__ not defined\n");
#endif

    return 0;
}

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "compilerPath": "C:/mingw-w64/8.1.0/mingw32/bin/gcc.exe"
        }
    ],
    "version": 4
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature: ConfigurationAn issue related to configuring the extension or IntelliSenseLanguage ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions