Why are uninitialized const members handled differently in C than in C ++?

I include the C header for lib that I am contacting. The header has a structure foofrom which I want to declare a new variable bar. I get a compiler error:

 error: uninitialized const member in "struct foo"

It makes sense that these members must be initialized, since subsequently they cannot be assigned values. But a C program using this library does the same thing, and it works. Is there a difference in the standards of C and C ++?

This is just a sample. Actually, I mean the structure mtd_dev_infofrom libmtd.h(mtd-utils). http://mtd-utils.sourcearchive.com/documentation/1.4.4/libmtd_8h_source.html

Structure in title:

struct foo
{
    int major;
    int minor;
    int type;
    const char type_str[15];
    const char name[15];
};

My C ++ Application:

int main (int argc, const char ** argv)
{
  foo bar; 
}
+4
1

, const.

, - ( ).

C , undefined, .

+3

Source: https://habr.com/ru/post/1545645/


All Articles