6 ms·
The Great C Runtime Refactoring
- pjmlp 12y ago"We have converted most of the CRT sources to compile as C++, enabling us to replace many ugly C idioms with simpler and more advanced C++ constructs. " +1 I love it.
- norswap 12y agoDo I smell irony?
- pjmlp 12y agoYeah, eventually people will have to accept that C is dead on Windows (Visual Studio), unless Microsoft's management decides otherwise.
- whoopdedo 12y agoOf course they wouldn't have to do that if they had a functioning C compiler. But snark aside, this is going to help GCC and CLang which will be able to target the stable runtimes. It doesn't matter than VCRuntime will continue to be versioned since each compiler will provide its own startup and EH (they already do). In fact, I wonder if this is a move to begin officially supporting alternate compilers. Is VCExpress going to be replaced with a LLVM-based package? Will it be possible to create a shim msvcrt.dll that forwards to the new libraries? Then old programs can finally take advantage of bug fixes.
- aktau 12y agoAll very well, but I'd be really happy once (if) we ever get proper C99 support in MSVC. We basically need that at the neovim project if we want our code to compile with MSVC. We don't want to compromise either, by for example compiling as C++ and not using some C99 features (we do use compound literals, we don't cast from void pointers, et cetera). The CRT improvements in MSVC 2013 and 2014 are a step, but only a small one. Sadly, compiling as C forces some kind of old mode where we can't even use declare-anywhere. For now, it seems like we'll need to let MingW and its offspring do it. Does anyone have a workaround?
- pjmlp 12y agoNever going to happen. For Microsoft C's time is passé. Herb Sutter already stated this multiple times. He was very clear that C99 support was only was is required by the C++ standard and to allow specific well known open source projects, which he referred to, to be ported to Windows.
- pavlov 12y agoSo it's "only" required by their primary language standard, as well as used in some very popular software... If that's barely enough to move Sutter into action, I wonder what would be an actually compelling case to him. The heavens open and a booming voice commands him to implement features X, Y and Z?
- taspeotis 12y ago> their primary language I read somewhere that Microsoft settled on C89 for the Windows kernel etc. so as far as their primary language goes their compiler implements it just fine.
- pjmlp 12y agoKernel code is being made C++ compliant according to a BUILD session when the going native wave started. As of Windows 8 is possible to use C++ for kernel code (vc++ got a new flag /kernel).
- pjmlp 12y agoVisual Studio 2013 launch http://events.visualstudio.com/eng/visual-studio-2013-launch/visual-studio-ide/iso-cplusplus-additions-in-visual-cplusplus/?SessionID=7508 http://events.visualstudio.com/eng/visual-studio-2013-launch... At minute 18:51. Focus is C++, there are no plans for C conformance.
- anon4 12y agoSounds like the next (2015) version should implement a lot more C99 compatibility, if I'm reading between the lines correctly.
- rogerbinns 12y agoI was expecting them to figure out symbol versioning (eg how glibc deals with the similar problem). It isn't clear if they have done that, or instead are hoping to always have backwards/forwards compatible code and data structures.
- jasode 12y agoFrom the blog post: >We have eliminated most of the manual resource management in the code through the introduction of several special-purpose smart pointer and handle types. Enormous functions have been split into smaller, maintainable pieces. We have eliminated 75%(2) of the conditional compilation preprocessor directives (#ifdef, #else, etc.) by converting internal implementation details to use C++ features like templates and overloading. FYI... The author of the blog post (James McNellis) also has an excellent video presentation that explains that paragraph in more detail. http://channel9.msdn.com/events/TechDays/Techdays-2014-the-Netherlands/Modernizing-Legacy-C-Code http://channel9.msdn.com/events/TechDays/Techdays-2014-the-N...
- Karellen 12y ago"Before this refactoring, the sprintf functions, which write formatted data to a character buffer, were implemented by wrapping the result buffer in a temporary FILE object and then deferring to the equivalent fprintf function." *headdesk*
- cremno 12y agoThat's actually common practice. Look at other libc implementations. Even the original implementation did that: http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/libc/stdio/sprintf.c http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/libc... http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/libc/stdio/fprintf.c http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/libc...
- nnq 12y agoNice to see them talking about C99, even after they said the focus is only C++... when for everybody else, the horizon is C11. Guess it's something along the lines of "let's handicap a bit all open-source projects that want to support Windows by forcing them to use an older language version that also has platform specific gotchas, maybe even rewrite the runtime to add more platform specific goodness"...
- frik 12y agoI doubt that GCC (MinGW) will be able to use this. What a pitty. MinGW relies on the CRT that ships with every Windows since Win95 (and Visual Studio 6). Microsoft could fix this situation by merging the CRT that ships with Windows (the original one) and Visual Studio (the forked of version madness) together. A simple Windows update for Windows NT 5.x+ would be great (of course it should be backward compatible).
- malkia 12y agoI kind of joked here: https://news.ycombinator.com/item?id=7843301 https://news.ycombinator.com/item?id=7843301 - but now I can't really wait for it. This is huge! This means that once major products pick up and develop their creative tools (Maya, MotionBuilder, Photoshop, etc.) - plugin developers no longer have to ship for multitude of CRT versions. Also finally things like Python, Perl, etc. can stick on one runtime and not care for a very long time. Great stuff Microsoft! I really really can't wait for it. I don't care even if no new C++ features are implemented - only this is that important.