C11, yo
lcinexile.blogspot.fr
lcinexile.blogspot.fr
:(
There is a world outside of Linux and mobile.
On the other side of the fence Microsoft has repeatedly stated that they are not interested in supporting more of ISO C than they already do and want to focus on C++ (even going so far as to recommend the C++ compiler for developing C code). And apparently that "focus" on C++ hasn't even helped them overtake or even get even with their free (beer and freedom both) alternatives. That goes a long way to show in what state their compiler division is and so I wouldn't even bet on getting anything halfway decent should they commit to C11. That is not to say that there are highly competent people on that team, but there is simply to much to do and too many old mistakes to rectify first.
>* For C++11 conformance, we're interested in implementing the C99 Standard Library
Source: https://connect.microsoft.com/VisualStudio/feedback/details/...
Nothing is more infuriating than half-baked support that makes you run around with feature tables and obscure seemingly arbitrary coding guidelines ("use only this subset of this feature", "if you use this thing, remember to have a workaround for VS").
Anyone here able to comment on what difficulties the VS team faces?
There's no way Windows developers are going to stop using Visual Studio - and rightly so, because it's a very good IDE. So there are basically three things Microsoft could do to resolve this situation and let Windows developers make use of modern C code:
1. Update their C89 compiler to a newer C standard. This is unlikely, and probably a lot of work for Microsoft (I'm guessing they'll be removing the C compiler from one of the next releases of Visual Studio).
2. Add support for essential C99/C11 features to their C++ compiler, such as designated initializers. This would still force us to compile our C as C++ and do nasty things like casting the return type of malloc, but it might be the easiest solution.
3. Switch to a modern, open source C compiler like Clang. I would be very surprised if Microsoft would do anything like this (else IE would be using WebKit already).
So we're basically forced to either butcher our C code to make it compile as C++, or write C89. Or drop MSVC support, making our projects difficult for Windows developers to work with.
Not many developers on Linux and OSX are going to hold out on using new features just to coddle Windows users.
Not everyone is allowed to use modern versions of clang and gcc.
From a technical perspective, though, the latest standards are easily usable on AIX. IBM has done a good job of keeping XLC up-to-date, and it has supported C11 since May.[1]
[1] http://www.ibm.com/developerworks/rational/library/support-i...
Another option is the Intel C(++) compiler, integrated directly into Visual Studio.
Also i took this opportunity to use LLVM/clang, Qt5, Qt Creator and all in all i'm really surprised. I thought everything would be much more cumbersome, i'd have to dig through terrible error messages or reinvent basic stuff on my own, but so far the stdlib and Qt offer what i need.
If you're like me amd avoided C/C++ like the plague, i'd suggest you try again next time, it may not be as bad as you remember :P
That is, until you overflow the stack with no way to know if that's going to happen and no way to recover if it does.
Secondly, I don't have access to the official standard, but it would surprise me if it required VLA's to be stack allocated. That would give implementers of the language too little leeway.
In fact, I see no clear reason why the standard would mention the word 'stack' at all. A quick check of the candidate PDF of the standard seems to confirm that, but that's not the real standard, and it may be a shortcoming of the iOS PDF reader.
However, what I like to see in C are "//" style comments, declaring variables at other places than start of scope, the integer types with bit size specified, etc...
But the VLA's? They're created on the stack, right? So you'd need malloc for large ones anyway.
What actually would save time (for the coder of course) in C, imho, would be a way to automatically clean up resources no matter where you exit a scope or function. Something like destructors do in C++. E.g. if you could type something like "onleave free(myresource);" which would execute what you type after "onleave" whenever the scope exits.
However, what I like to see in C are "//" style comments, declaring variables at other places than start of scope, the integer types with bit size specified, etc...
All of those are already in C99...And malloc() takes more time than subtracting a variable from the stack pointer. Though VLAs have pitfalls so you probably don't want to use them outside of throw-away code anyway.
Good news, those are both part of C99 (http://en.wikipedia.org/wiki/C99), which is supported by both GCC and Clang.
"Static compile-time assertions allow the use of sizeof() and friends" could already be done with the preprocessor and typedefs; see e.g. C_ASSERT: http://msdn.microsoft.com/en-us/library/windows/desktop/ms67... It will still be nice to have a standard way to do it, though.
"We do not plan to support ISO C features that are not part of either C90 or ISO C++."
http://herbsutter.com/2012/05/03/reader-qa-what-about-vc-and...
Really, I think we'd be better off if they actually removed it from future toolkit releases. That way no one would be confused into thinking that Microsoft supported C.
For this reason I'm not planning on allowing the use of C11 features in e2fsprogs, because I know there are people compiling libext2 so they can access ext[234] filesystems using FUSE on Windows (and MacOS, but MacOS is at least using a reasonable compiler).
If, because of parameters outside the programmer's control, a call to malloc() fails to allocate an array of n doubles, it returns NULL.
If, because of parameters outside the programmer's control, the variable-length definition “array double arr[n];” fails to allocate an array of n doubles, the behavior is undefined.
Your choice.
The thing about C is that programmer should do check size before calling function with double arr[n]. Isn't that point of C? On the other hand, user can make fast stack allocation which, depending on situation, can be good. Stack is insecure by default, OS should put it really far from other parts. In embedded systems, well there you must always think about these kind of things.
Btw, how are (p)thread stacks implemented? Every thread has it's own stack, that's ein interesting situation.
I have no idea why you would be asking me this, unless you are quibbling over the idiom associating the verb “allocate” and the complement “on the stack”, in which case Google should be able to find you about 56000 uses, in context, of this precise association.
> The thing about C is that programmer should > do check size before calling function with double arr[n]. > Isn't that point of C?
What part of “because of parameters outside the programmer's control” do you not understand? What limit, in a portable C program, do you check the value of n against before allocating a VLA of size n?
I'd say writing as much code as possible in other languages (whether guile or perl/python/ruby/java/...) improves portability. C code tends to be less portable than that written in higher level languages.
Maybe not for ruby, but I'd certainly expect most new processors to run Java. A quick search suggests there are ruby interpreters for blackfin - and if you have a ruby interpreter you can be reasonably confident any given ruby program will behave correctly on it.
Or are you talking about the ruby interpreter written in C running on an OS written in C?
Java is available? Again are we talking about a bare-metal Java compiler (possibly supported by hardware being able to execute a subset of Java natively), or the large collection of software written in C and C++ that is supplied by Oracle?
No this is not inconsistent; I said move as much code as possible away from C. That which is impossible to move has to stay in C (and will probably be responsible for 99% of the headaches when porting to a new architecture).
I disagree. A google search for blackfin ruby interpreter did not suggest that to me.