close
Namespaces
Variants

Talk:c/language/inline

From cppreference.com
static int x;
inline void f(void)
{
    static int n = 1; // error: non-const static in a non-static inline function
    int k = x; // error: non-static inline function accesses a static variable
}

There is no error in visual studio 2022. Does it ignore the standard?

yes, MSVC's C compiler is far behind its opensource alternatives in both language/library support and in specific compliance tidbits like this one (to be fair, standard allows it to invent meaning for this code, it only requires that there's a way to issue a warning) --Cubbi (talk) 09:32, 28 September 2023 (PDT)