Hacker News new | ask | show | jobs
by asveikau 2296 days ago
Mixed declaration and code is very old in C++, and Microsoft has always supported it there. It wasn't until vs2015 that they let you do it in a .c file.
1 comments

Sure they did let do it, as long as that C file as compiled as C++.
There is a "C language mode" inside cl.exe (by file extension or by /TC flag) and there's plenty of C that doesn't compile as C++.

eg.:

   char *p = malloc(n);
No explicit casts from void*!

Anyway, around the time they started allowing mixed declarations and code in a .c file, I was noticing on-the-job that this was becoming a disproportionate source of build failures in intended-to-be-portable .c files my colleagues were writing on Unix. It was as if cultural memory of pre-C99 declaration requirements was disappearing specifically around that time. So it makes sense to me that they went ahead and added it. They probably got a lot of complaints.