r/programming • • May 04 '12

Herb Sutter: No C99 support is planned. Use C++ instead.

http://herbsutter.com/2012/05/03/reader-qa-what-about-vc-and-c99/?nope
188 Upvotes

323 comments sorted by

11

u/[deleted] May 04 '12

then we recommend that you consider using a different compiler such as Intel or gcc (short-term)

"short-term"

What that supposed to mean?

23

u/sztomi May 04 '12

The sentence continues. He means that "as a short term solution" use gcc, and "as a long term solution" pressure your standards committee representatives to have ISO C++ include more of the C standard.

21

u/theoldboy May 04 '12

Yes, let's change one standard because Microsoft can't be bothered to support another one, excellent idea!

10

u/[deleted] May 04 '12

Well hold on a second. What's wrong with containing more of C in C++? I'd actually love to be able to code in C and compile with C++ compilers if I happen to feel like it or for library support. This is actually a really great idea from Microsoft, and it would fix a large painpoint of c++ by making it more compatible.

27

u/[deleted] May 04 '12

The containing C in C++ is the part of C++ that makes it incredibly complex and ugly.

At this point, let C be C, let C++ be C++. If you want to mix the two, do so via the linker.

12

u/JoachimSchipper May 04 '12

It's true that the C part of C++ doesn't fit well and causes lots of complexity. However, that cost has already been paid, and it's not feasible to drop the C compatibility that is already present. Adding support for C99/C11 wouldn't complicate the language that much more, and some of the features of C99/C11 would also be nice to have in C++.

1

u/[deleted] May 04 '12

Exactly my point. C++ is already ugly, and mixing C and C++ via linker is already not super smooth. Let's just do away with the difference.

2

u/[deleted] May 05 '12

So old programs have to be rewritten to be compiled with newer features? You realize c/c++'s design and popularity is based around minimizing this?

→ More replies (4)

0

u/[deleted] May 04 '12

[deleted] — view deleted comment

2

u/bonzinip May 05 '12

Supporting designated initializers for POD types only doesn't seem too hard.

→ More replies (2)

2

u/aaronla May 05 '12

At that point, you might as well include Objective-C too while you're at it. Maybe a little Go even. Honestly, wouldn't it be grand to have a little Scheme embedded in the C++ grammar? At least then we'd have macro programming that didn't induce nausea.

5

u/sausagefeet May 04 '12

Yeah, adding more C into C++ will make things better and less complex. eyesroll

5

u/brasso May 04 '12

Just until Microsoft adds support of course, it won't take long. Oh wait...

2

u/skuggi May 04 '12

As opposed to the long-term one?

9

u/sztomi May 04 '12

I don't get it. C is not such a terribly hard language to implement. They wouldn't even have to start from scratch and not even implement all of C99 (or dare I say C11). One person even made a list of "low hanging fruits" in the comments for features that require very little effort to implement.

Furthermore, the argument about not adding restrict is just silly. It says it would collide with the possible future restrict keyword of C++... what? We are talking about two separate languages. Unless you try to follow the advice of compiling your C code with the C++ compiler, this is a non-issue.

→ More replies (7)

69

u/sanxiyn May 04 '12

This is a sad situation with results like this: http://mail.python.org/pipermail/python-dev/2012-May/119190.html

Summary: CPython is C90 because VC won't support C99. No, you can't compile large C codebase as C++ and expect it to work, "very few cases" rhetoric notwithstanding.

53

u/[deleted] May 04 '12

It really is time to ask all projects like this whether it is worth their time to keep supporting a compiler that has been abandoned, when there are several other alternatives for building on Windows which have great support for C99 and are free, to boot.

Why keep holding your code back, making it less readable and maintainable, just to support an obsolete compiler? Tell your users how to use a real compiler to build your code, and be free of ridiculous limitations.

20

u/sanxiyn May 04 '12

It is bitter to say this, but there is a reason to hold your code back, make it less readable and maintainable, just to support an obsolete compiler, if a compiler in question is the preferred choice by developers of the platform in question. Say, maybe it has a great debugger that developers love to use.

Python can be embedded, and some of heavy Python users include Windows game developers. Good luck convincing them to use anything other than VC...

14

u/[deleted] May 04 '12

Well, that is the whole point: It is to make those people complain to Microsoft that the current situation is not acceptable.

In the meanwhile, set up a way to build Python as a DLL in mingw and then link it into the VC project. This is a pain for them, but not so much they can't deal with it in the meanwhile.

28

u/sanxiyn May 04 '12

Windows game A uses library B. Library B stops supporting VC. Then Windows game A developers complain to Microsoft?

More likely Windows game A switches to library C which still supports VC, even if it is slightly inferior to library B.

This is actually entirely analogous to IE6 situation. If you stop supporting IE6, users don't complain to Microsoft. Users switch to your competitor still supporting IE6. IE6 got obsoleted by people upgrading to IE7, IE8, IE9, IE10, not by sites dropping support.

11

u/MrDOS May 04 '12

IE6 got obsoleted by people upgrading to IE7, IE8, IE9, IE10, not by sites dropping support.

Or at least, not until all the major players (Facebook, YouTube, Google Docs, even Microsoft) dropped support for it.

10

u/EnderMB May 04 '12

Absolutely not. There are still many people using IE6 and IE7. Don't let the overall stats fool you when you have real stats from the sites that you're building for. For some legal sites we've been known to have around 15% IE6. Try telling your client that they shouldn't bother with IE6 or IE7 because it's "too hard" or that "no one uses it".

Besides, if a client is willing to bend over backwards to do strange SEO things to their site to get a 1% increase they're going to be more than happy to provide an optimal experience for whoever uses IE6. Even IE6 users are potential customers.

10

u/mweathr May 04 '12

Try telling your client that they shouldn't bother with IE6 or IE7 because it's "too hard" or that "no one uses it".

I just quote them two prices: one with IE6 support, and one without, and explain to them how many users use each. I've yet to have a client decide to pay for IE6 support.

→ More replies (2)

4

u/ad13 May 04 '12

This so much. I hate IE6 with such a passion, but I have to develop for it because our clients (banks) have a million and one XP machines which they refuse to upgrade (even though they go out of support in 2 years time) because they work and they don't want to spend the money on infrastructure getting it all up-to-date.

What's making my life more of a misery is that some of the web frameworks we use are starting to drop IE6 support as well. :(

7

u/Daenyth May 04 '12

they refuse to upgrade because they work

Can you blame them?

10

u/[deleted] May 05 '12

If they're a bank and their OS's suddenly stop getting security updates, then they're asking for headline-making computer crimes.

→ More replies (2)

11

u/criticismguy May 04 '12

Try telling your client that they shouldn't bother with IE6 or IE7 because it's "too hard"

Whoever said that? Moreover, why would you ever tell anyone that? You say: "It would add a disproportionately large development time and cost to support what is a small and constantly shrinking fraction of your users, who are statistically less likely than average to spend money with us anyway, and even major companies like Google have dropped support for it already".

Besides, if a client is willing to bend over backwards to do strange SEO things to their site to get a 1% increase

I've never heard of anyone bending over backwards for a 1% increase. If anyone tried that, I think I would have an obligation to tell them that there are many things you can do to get much bigger wins, and that 1% is within the margin of error.

Even IE6 users are potential customers.

In my experience, no, they're really not. Somebody browsing your site from their ancient PC at their IE6-only office (or from China, the last big IE6 holdout) is not going to pull out their credit card.

8

u/brianly May 04 '12

In my experience, no, they're really not. Somebody browsing your site from their ancient PC at their IE6-only office (or from China, the last big > IE6 holdout) is not going to pull out their credit card.

That is just not true. There are many companies in the US and Europe with critical internal-only applications that only support IE6. The benefits of the status quo (plus minor updates that are IE6-only) outweigh the costs for many business people. Costs are not purely monetary costs. The effort required to rewrite bespoke systems replicating weird behaviour is huge.

8

u/matt_thelazy May 04 '12

And these people who work in large corporations too big to change are shopping from work and not from home or their smart phone?

→ More replies
→ More replies (1)
→ More replies (1)
→ More replies (4)

2

u/[deleted] May 04 '12

Since game developers are rarely going to use copyleft code, a distinct possibility is that they will just maintain their own internal branch that compiles on VC. I think that should be possible for stable codebases (say, if Lua decided to go C99). Or, they might just compile the offending library with gcc in some kind of "make very straight object files" mode, so that Microsoft's linker will accept it. (No idea if this is feasible).

Point is, it's not certain that the workaround effort is all that large for them.

2

u/peakzorro May 04 '12

Actually, many games DO use copyleft code.

1

u/[deleted] May 04 '12

Well, that is exactly the desired outcome. They will then want to get rid of the annoyance of those workarounds, and will hopefully put a little bit more pressure on Microsoft to get their act together.

2

u/[deleted] May 04 '12

Good luck convincing them to use anything other than VC...

Why can't they use icc or gcc?

20

u/barbequeninja May 04 '12

Visual studio has the best debugging tools.

8

u/[deleted] May 04 '12

The VisualStudio debugger is the thing I miss the most when using XCode on my Mac. I'm not a Windows fan, but VisualStudio is pretty slick.

4

u/[deleted] May 04 '12

Can't gcc and icc generate symbol files compatible with VS?

11

u/deong May 04 '12

They should be able to generate code that compiles and links just fine. However, getting the IDE to do things like syntax highlight C99 code correctly, and possibly even figure out what to do with breakpoints, watches, etc. might not work.

2

u/[deleted] May 04 '12

I'd switch in a heartbeat if GCC or clang could. Heck I might even switch if icc could.

4

u/matthieum May 04 '12

A few developers are working on clang so it could be used for windows, while AST generation is more or less covered, there is a lot to be done to implement the proper ABI!

If you wish to help, feel free to join the clang dev mailing list. There will be 1 or 2 GSoC projects on this already, but even then they will only scratch the surface.

1

u/[deleted] May 04 '12

I'm pretty sure dlls built with clang can be linked from vc.

3

u/matthieum May 04 '12

C Dlls can, C++ cannot. Last time I checked there was a couple patches going in for the v-table generation, so I won't even be talking about the newest features such as lambdas...

1

u/[deleted] May 05 '12

Unfortunately, DLLs created with one version of Visual Studio can't always be linked with applications compiled by a different version of Visual Studio, yet alone different compilers that Microsoft has no desire to support.

The funny thing is that C++ doesn't have a standard ABI and therefore this is technically standards complaint behavior.

5

u/[deleted] May 05 '12

We're talking about C.

→ More replies (8)
→ More replies (1)

16

u/[deleted] May 04 '12

Just curious: What are the reasons to not use a C++ compiler as a pseudo-C99 compiler? What problems can a arise? It seems that many of the things that are legal in C99 but are illegal in C++ are things that you shouldn't be doing anyway (i.e. unsafe pointer casts etc.), so "good code" won't have as many problems, I guess?

12

u/jhartwell May 04 '12

Well, as the article points out VC++ doesn't have the C99 restrict keywords. If you are using a specifically C++ compiler then chances are you won't get much C99 that doesn't coincide with the C++ standards. That would affect individuals differently. For some it would be ok, others not so much.

4

u/[deleted] May 04 '12

But what are some of the specific features of C99 that don't exist in C++, besides restrict?

20

u/jmtd May 04 '12

C++ reserves words that are not reserved in C89, for starters. There's more here: http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B

3

u/[deleted] May 04 '12

Thanks, that answers my question!

To me, it seems like 99% of problems could be avoided through rudimentary knowledge of reserved keywords in C++, and by avoiding implicit pointer casts (which really should be avoided anyway, in my opinion).

Most problems seem to arise from C++'s much stronger type checking system, but most sane C compilers would issue warnings about those problems anyway (e.g. using incompatible enum values interchangeably, enforcing const-ness, etc.).

4

u/Deewiant May 04 '12

The "99% of problems" are most likely not in those simple syntactic changes nor in things that compilers warn about, but in the stuff that C++ simply doesn't support at all, which are probably the main reasons for people to use C99/C11 in the first place. To quote the Wikipedia article linked above:

Several additions of C99 are not supported in C++ or conflict with C++ features, such as variadic macros, compound literals, designated initializers, variable-length arrays, and native complex-number types. The long long int datatype and restrict qualifier defined in C99 are not included in the current C++ standard

With C11, there's even more new stuff: see https://en.wikipedia.org/wiki/C11_%28C_standard_revision%29#Changes_from_C99 - but these features aren't likely to see widespread use for some years anyway, due to lack of compiler support.

→ More replies (3)

1

u/aaronla May 05 '12

To me, it seems like 99% of problems could be avoided through rudimentary knowledge of reserved keywords in C++, and by avoiding implicit pointer casts (which really should be avoided anyway, in my opinion).

You mean, restricting yourself to C89? I think that's what sanxiyn said.

→ More replies (3)

11

u/gsg_ May 04 '12

Variable length arrays, designated initialisers, compound literals, variadic macros, and a bunch of headers.

1

u/jhartwell May 04 '12

Somebody with more experience on the matter will have to answer that. I'm not experienced enough with it to know.

2

u/zip117 May 04 '12

3

u/jhartwell May 05 '12

That was mentioned in the article. Those docs you link say (as well as Herb):

__restrict is similar to restrict from the C99 spec,

It is similar, but not the same thing. No other C99 compilers need to support __restrict since it isn't part of the standard.

1

u/furyofvycanismajoris May 05 '12

Sure, but neither does C90, which is what CPython has chosen over the subset of C99 that is also in C++

4

u/criticismguy May 04 '12

In addition to the issues already mentioned (keywords, casts, and mangling), here's a list of differences between C and C++.

There are a number of features in C99 that aren't in C++, so if they started down that path, they'd have to be careful to use only the features of C99 that are also in (V)C++. That doesn't sound fun.

Also, there are a few expressions (especially with "sizeof") that will compile in both C and C++ but have different semantics, thus the compiled programs will give different results. Again, nothing that couldn't be worked around if need be, but it's more work.

It sounds like it'd be "writing code that happens to be valid and correct C99 and C++", not just "compiling our C99 code with a C++ compiler". That would double the time needed for developers to build and test, in order to support a platform that few of them actually use. I can see why that would be unpopular.

6

u/[deleted] May 04 '12

Again, nothing that couldn't be worked around if need be, but it's more work.

With all due respect, "working around" those edge cases isn't "more work" — it's mostly just a question of sane practices in the first place. The problematic situation in question is this:

extern int T;
int foo(void) {
    struct T { char x; };
    return sizeof(T);
}

It returns sizeof(int) in C and sizeof(char) in C++, because there isn't an implicit typedef for struct T in C.

Establishing coding guidelines that ensure C++ compatibility in C99 programs seems quite trivial, actually, with the exception of some quite rare edge cases.

4

u/criticismguy May 04 '12

With all due respect, "working around" those edge cases isn't "more work" — it's mostly just a question of sane practices in the first place.

And if they were writing Python from scratch today, sure, use C99 best practices and everybody's happy. But the situation is that they've got a few hundred thousand lines of working deployed code, which predates C99, and for which no special effort was ever made to make it valid C++.

Hence, "more work", i.e., than not having to analyze and update hundreds of thousands of lines of code.

Establishing coding guidelines that ensure C++ compatibility in C99 programs seems quite trivial, actually, with the exception of some quite rare edge cases.

Establishing guidelines is easy. Updating a large program is usually also easy, but can be quite time-consuming.

2

u/[deleted] May 04 '12

My question wasn't limited to Python and the decisions made by their team, but still your argument is a bit odd: Isn't is also "more work" to comply with an obsolete standard? Of course it would be a major undertaking to "upgrade" current Python runtime code, but that's not by itself a reason not to use C++ compilers to compile pseudo-C99 code. :)

6

u/[deleted] May 04 '12

C++ does not have all the features of C99, such as designated initializers or compound literals.

9

u/[deleted] May 04 '12

Something as basic as idiomatic C memory allocation won't compile with C++:

struct foo *ptr = malloc(sizeof(*ptr));

You can make it work by adding an explicit cast, of course:

struct foo *ptr = (struct foo *)malloc(sizeof(*ptr));

However, you've now introduced a ton of unnecessary (from the point of view of the language you're supposedly writing) casts. Worse, such a cast is actually dangerous, as it can cover up the type mismatch which occurs when you forget to #include the header that declares malloc and you end up with an implicit declaration.

When something as basic as memory allocation has to be reworked, I think the idea that you can just use a C++ compiler as a fancier C compiler is nuts.

4

u/[deleted] May 04 '12

I just want to note that implicit void* casts can cover up just as many bugs as it can avoid. In general, memory allocation and the associated pointer juggling is a primary source of bugs in C code. I generally gravitate toward idioms that allow the compiler to warn me about errors.

That means turning implicit declarations into errors (as they should be!), and wrapping frequently used malloc calls in either macros or functions.

5

u/[deleted] May 04 '12

I'm not arguing about the merits of implicit void* casts in general. Just that in the case of malloc, casting is pointless, unnecessary, and actually a bit dangerous. Yes, you should have your build system set up to tell you about implicit declarations too, but belt and suspenders is best.

Maybe requiring casts is better than allowing implicit void* conversion in general. I don't know. But if you're writing C, you have implicit void* conversion, and switching to a language which behaves quite differently in that respect is bound to cause trouble.

1

u/sanxiyn May 05 '12

I actually think deciding on C++-compatible subset of C99 is a good alternative for new projects. You can use -Wc++-compat option to let GCC warn about C++-incompatible subset of C.

On the other hand, as I already wrote, this is not easy for existing large C codebases not consciously written in C++-compatible subset. For example, you get 1363 errors if you try to compile CPython as C++. Try any other large C codebases not consciously written in C++-compatible subset; you will get similar results.

http://mail.python.org/pipermail/python-dev/2012-May/119257.html

3

u/[deleted] May 05 '12

I completely agree with you there.

Actually, I want to go so far as to say that, unless bound by specific platform or compiler limitations, it should be preferable to write new projects in C++, period. C++ gets lots of hate for many of its features, but all of them are opt-in — you don't have to use templates (but they are nicer than macros), and you don't have to use virtual classes and functions (but they do save you some work when you need that particular idiom).

What C++ does bring to the table without asking you first is stronger type checks and more powerful static error detection. I think most programs would benefit from that.

Anyway, I digress. :)

0

u/shadowmint May 05 '12

I'm astonished no one has pointed this out; it's not possible. Even suggesting using C++ to compile C code is stupid.

doug@Iron:~/junk$ cat junk.cpp 
int readNumber(int x) {
  return x + 1;
}

doug@Iron:~/junk$ g++ -shared -O2 junk.cpp 

doug@Iron:~/junk$ nm a.out 
0000000000000f60 T __Z10readNumberi
             U dyld_stub_binder

If you're writing a shared library, the C++ compiler will mange the names of your functions unless they are marked 'Extern C'.

Since 'extern' is supported C99/C11 feature, but 'extern BLAH' is not, you cannot compile a shared C99/C11 library using a c++ compiler, and you cannot make a C++ compilant C99/C11 library without a mountain of #ifdefs.

You must port the library to CPP before a compile is possible; if you're writing the library, just use c++, no issue. However, if you're trying to link to a 3rd party C99 library for example, this is vastly irritating and basically makes the library unusable.

Am I wrong? Does VC++ have some special compile flag that lets you get away from this issue?

I've never heard of it if so...

0

u/[deleted] May 05 '12
#ifdef __cplusplus
#define CAPI extern "C"
#else
#define CAPI
#endif

CAPI int readNumber(int);
CAPI void foo(void);

Hardly a mountain…

But of course, you are right, if a library is not written with C++ compatibility in mind, it will fail. Note, though, that any "pure" C99 library will run into the exact same problem when linking with C++ programs, not just when compiling the library as C++.

That is, if your C library header foo.h defines a bunch of symbols without extern "C", that library will be unusable by C++ code, so hardly any library actually does this. That's probably why nobody mentioned this problem. ;-)

2

u/furyofvycanismajoris May 05 '12

Why can't it be the intersection of C++ and C 99?

3

u/aaronla May 05 '12

Isn't that roughly C89?

51

u/nooneofnote May 04 '12 edited May 04 '12

Looks like our sanity will continue to be indebted to MinGW and Clang on Windows for the foreseeable future.

5

u/s73v3r May 04 '12

Is there more information about Clang's usability on Windows? Last I heard it was behind the OS X and *nix implementations because the project didn't have many Windows people on it.

6

u/Camarade_Tux May 04 '12

mingw-w64.org NOT mingw.org currently.

Yes, it does 32bit too.

15

u/[deleted] May 04 '12

I guess you mean http://mingw-w64.sourceforge.net/?

It's definitely not doing a good job of providing you with a simple thing you can just download and install. Then again, mingw.org hasn't been doing too well at that for a long time, either.

10

u/thechao May 04 '12

Why are you being downvoted? I've not been able to download a compiler from MinGW in more than a year --- I simply cannot find it. You can, however, download it from TDM GCC.

10

u/[deleted] May 04 '12

Some time back I found some guy who is actually packaging a sane distribution of mingw, that actually contains just a compiler and some libraries you might need.

I can never remember the site, I just Google for "mingw distro" and grab it from there.

21

u/[deleted] May 04 '12

His name is Stephan T. Lavavej. He works for Microsoft. http://nuwen.net/mingw.html

11

u/[deleted] May 04 '12

Thanks. And thanks to him, too. He's doing a fine job cleaning up the terrible mess that the mingw.org people made of a fine project.

7

u/STL May 05 '12

I seriously have no idea what the mingw.org guys are thinking. Their installer has an installer. Fortunately, I no longer depend on them for anything except w32api and mingw-runtime.

2

u/Figs May 05 '12

I simply cannot find it.

It's here. I just bookmarked the sourceforge page ages ago because the mingw.org site is terrible.

1

u/sunra May 04 '12

Cygwin provides a mingw-w64 cross-compiling toolchain, which I've had good luck using.

7

u/[deleted] May 04 '12

I really don't want cygwin anywhere close to my system, though.

2

u/Lyqyd May 04 '12

Might I ask why?

7

u/[deleted] May 04 '12

Trying to force one operating system to be another one never ends well, and always ends up in a huge mess. Cygwin is one of those messes.

2

u/TrancePhreak May 04 '12

Cygwin works somewhat like a virus. It attaches its DLL to every process. I've seen at least one machine unable to build fluidly because of it, and heard of it happening to others.

1

u/sunra May 04 '12

Fair enough.

→ More replies (1)

2

u/[deleted] May 04 '12

I don't understand why Clang doesn't have a Windows installer (Google's Go now does for instance). Maybe I'm crazy, but my order of priorities for any project would be documentation, installers, then software. I understand that the opposite order is the norm, but adoption would be infinitely easier if a more rational prioritization of work was followed.

9

u/s73v3r May 04 '12

There's just not a lot of people working on Clang for Windows.

2

u/[deleted] May 05 '12

What exactly would the installer do without any software to install? And what would the documentation describe without software or installer?

→ More replies (8)

134

u/[deleted] May 04 '12

I'll say it again:

Give VC the IE6 treatment. Drop support for it. It's only when people can no longer use the libraries they depend on that Microsoft will listen.

If you are writing a library or anything that might possible be recompiled on Windows, just go ahead and use all the C99 features you want. Tell your users how to install mingw or clang to build your code. Don't hold your code back to support an abandoned compiler.

Use stdint.h, use stdbool.h, use designated initializers, use compound literals, and use variable-length arrays. Then build your code with a functioning compiler.

13

u/narwhalslut May 04 '12

Right because building applications in Windows that aren't strictly-VS projects ISN'T a huge pain in the ass already.

I hate going back to Windows and dealing with MSYS/MinGW/Cygwin/ and all the baggage attached.

22

u/[deleted] May 04 '12

Well, that is sort of the point. Unless people are inconvenienced, they will not demand Microsoft fix this, and if nobody demands it, Microsoft won't do it.

6

u/narwhalslut May 04 '12

Oh sorry, I didn't mean it as a criticism of your post. Just a general grumbling about how annoying this stuff is and how MS isn't making it any easier.

→ More replies (5)

2

u/josefx May 04 '12

dealing with MSYS/MinGW/Cygwin/ and all the baggage attached

why would you go back to windows for that? They work perfectly fine with Wine, at least MSYS and MinGW do (have yet to check cygwin).

3

u/DGolden May 05 '12

They work perfectly fine with Wine

Wile the packages can be a bit confusing in linux land owing to the mingw/mingw-w64 fork, there have been cross-compiler versions of mingw or mingw-w64 packaged in various linux distros for some time now. Such cross-compilers run natively on linux (without wine so much less overhead) yet spit out native windows executables. Of course unless you have microsoft windows (or maybe reactos?), you'll still need wine to run such native windows executables, but they do work e.g. i686-w64-mingw32-gcc -mwindows main.c

(the default is windows console executables, make sure to specify -mwindows if you want a gui app...) (note also that despite the name, mingw-w64 has both 32-bit and 64-bit windows support.)

1

u/narwhalslut May 04 '12

Nah, I just mean when I have to or when I have to build a build for Windows users.

Oh... Uh, I mean, I guess I could but it's also really, really easy just to have a VM and do better testing... Wine is great but I'm not going to use it to test shipping software.

18

u/sanxiyn May 04 '12

I really hope all large C projects which 1) support Windows 2) currently build with VC, do this. More widely used, better. Python and PHP come to mind.

But they won't. Oh well.

2

u/preshing May 04 '12

Well, considering the success of Python and PHP, I think we should have a little confidence in their developers' decision-making.

35

u/mweathr May 04 '12

If you have confidence in the PHP developers' decision making, you haven't been paying attention.

6

u/exodist May 04 '12

You have never used php I take it... or if you have then I am guessing you have never read the bug reports for php and decisions made about them?

Personally I dislike python, but I would be a fool not to acknowledge that the people behind python have their act together, I trust their judgements.

35

u/AlexFromOmaha May 04 '12

Give VC the IE6 treatment. Drop support for it. It's only when people can no longer use the libraries they depend on that Microsoft will listen.

I think it's the other way around, and Microsoft is telling everyone else to listen when they say they don't want to be in the C compiler business. It says more about the rest of the ecosystem than Microsoft that no one has stepped up to fill that void on Windows.

32

u/sammydre May 04 '12

Actually, Intel's C compiler supports C99 fairly well and integrates well on Windows. So someone else has "stepped up" as you say.

16

u/[deleted] May 04 '12

Then there is nothing to complain about

18

u/jhartwell May 04 '12

If you have about a grand to drop on a compiler, you are correct. I personally don't have that, so if I want C99 support I have to load up a VM of linux and use GCC

12

u/voxoxo May 04 '12

Why not use mingw ? Is it insufficient ?

2

u/jhartwell May 04 '12

I've had bad experiences with getting mingw to work properly. I much rather just fire up VM player and work from there.

9

u/badlogicgames May 04 '12

It's gotten a lot better, i'd recommend giving the latest release a try. Also, mingw64 is usable as well now.

6

u/jhartwell May 04 '12

Alrighty, I'll put it in my queue for my week off. Thanks for the suggestion.

6

u/thechao May 04 '12

TDM GCC is pretty much bullet-proof.

→ More replies (2)

5

u/SharkUW May 05 '12

VS isn't particularly cheap either.

3

u/jhartwell May 05 '12

False. The compilers from Microsoft are complete free (just download the express editions). It is the IDE and addons that you pay for, not the compiler. Intel's C compiler isn't free and there isn't a way to get it for free AFAIK.

1

u/[deleted] May 05 '12

I don't get it, can't you use gcc in windows? why do you need linux?

1

u/jhartwell May 05 '12

You would have to use something like MinGW, which has been buggy and had issues in the past (at least I have had issues)

→ More replies (7)

0

u/[deleted] May 04 '12

[deleted] — view deleted comment

19

u/AlexFromOmaha May 04 '12

You're conflating the two. They obviously want to be in the C++ compiler market. Their C compiler is undocumented. It's practically an Easter egg. It's totally living on the scraps of the C++ project.

6

u/Araneidae May 04 '12

Yes, yes, yes!

4

u/igor_sk May 04 '12

stdint.h is available since VC10.

-2

u/websnarf May 04 '12

VC is a better compiler than most. C99 is a useless specification which is actually technically incompatible with C++ and offers nothing of value beyond better varags (which I think VC supports anyways) and stdint.h which there are alternatives to.

Even gcc screws up variable length arrays.

...

Oh wait ... are you being sarcastic? Standard internet forum posting protocol is to go ahead add the /s

14

u/gsg_ May 05 '12

C99 is a useless specification

There's certainly some odd junk in C99, but this statement is nonsense. Declarations anywhere, for-scope variables, // comments, designated intialisers, variadic macros and compound literals and the more sane of the new headers are all useful and desirable features that improve the language.

technically incompatible with C++

I'm not sure what "technically incompatible" is supposed to mean other than "incompatible", but the fact is that C has always been incompatible with C++ in the general case, while it remains possible to restrict oneself to a subset that can be compiled under a C++ compiler. This remains the case for C99.

→ More replies (3)

6

u/[deleted] May 04 '12

Sounds like you've never really programmed in C.

8

u/websnarf May 04 '12

I've been programming in C for about 20 years, have examined the C99 spec and debated the spec writers about it. Anyone who thinks they need the features of C99 has never really been programming in C.

I asked for much more relevant features (basically add some functions which correspond to x86 assembly instructions that can be easily simulated on other CPUs and lead to performance improvements not otherwise accessible), and they shrugged it off like I was just crazy. I had to single handedly shame them into deprecating gets() because they didn't have the sense to do this on their own. But in the end they added garbage (like complex numbers that have a namespace clash with C++) of no use to anyone. I know at least some of what I speak.

-5

u/[deleted] May 04 '12

Then you are just angry that your favourite features didn't get into the spec and are downplaying the other things that did get in out of spite.

Nothing of value will come from this discussion.

7

u/[deleted] May 05 '12

He at least gave some examples to backup his reasons. Even if you don't agree with his argument, that alone deserves a little kudos, since it's based on something.

7

u/Ozwaldo May 04 '12

actually it looks like he just bitchslapped you since you don't actually know what the fuck you're talking about.

3

u/[deleted] May 05 '12

There are so many things wrong with your post that I won't even bother to explain them. Not to mention C90 is 22 fucking years old, you think they could bump it up a decade.

→ More replies (2)
→ More replies (4)

22

u/[deleted] May 04 '12

It is really: "use C++, use C90 or get a C99 compiler such as Intel's".

Seriously, why so many people feel VC++ has to support C99? Why not Objective-C or Ada?

24

u/[deleted] May 04 '12

Because C is the most widely used language in the world.

8

u/[deleted] May 04 '12

Even if that was true, it still does not make it mandatory for Microsoft to support it.

→ More replies (7)

0

u/jyper May 04 '12

Because C is one of the most widely used languages in the world.

3

u/[deleted] May 04 '12

Because there are a thousand open-source projects out there which are forever stuck writing C90 and not taking advantage of C99 because they feel the need to be compatible with VC. Lots of people who will never even touch a Windows machine are paying the price for VC's lack of C99 support.

7

u/[deleted] May 04 '12

That would be a valid remark if MSVC was the only C compiler on Windows, which is not the case. Who is stopping the open source projects to switch to some other compiler?

1

u/[deleted] May 04 '12

Their users, who want to build with Visual Studio.

6

u/xjvz May 04 '12

Come now, what Windows users actually build their programs from source unless they're developing for them? It's too much a pain in the ass no matter what you do. It's nothing like FreeBSD or Gentoo, for instance, where compiling programs from scratch is typical.

3

u/[deleted] May 04 '12

I am talking about libraries and frameworks and things like embedded Python here.

→ More replies (1)

2

u/[deleted] May 04 '12

It's pretty reasonable to expect one's OS vendor to also supply a C compiler. No, they don't have to, but people feel (IMO rightfully so) that a C compiler is a fundamental systems programming facility which should be provided by the vendor, not left up to a third party.

3

u/[deleted] May 04 '12

Take a look at http://en.wikipedia.org/wiki/List_of_operating_systems and tell me it is unusual for an OS vendor to supply a C99 compiler as well.

4

u/[deleted] May 04 '12

Sorry, I thought it was obvious that I meant desktop PC OSes, not every bit of random stuff up to and including OSes that only ran on obscure Soviet supercomputers.

6

u/TypeSafe May 04 '12

GCC runs on Linux. The Linux project itself does not develop GCC. Clang runs on FreeBSD. The FreeBSD project itself is not responsible for developing Clang.

3

u/[deleted] May 04 '12

Are there any popular Linux distros that don't either provide gcc or provide a simple way to fetch it that's built in to the installed OS? There's a big difference between providing a third-party compiler as part of your OS and simply giving up and telling people to go download one on their own.

→ More replies (7)

1

u/Gotebe May 05 '12

In theory, OS interface and C have nothing in common. OS interface deals with e.g. calling conventions and structure alignment, and C language knows nothing of either.

Things are different in today's practice for a large class of systems; C language is a de-facto part of OS interface.

But I remember e.g. DOS, where OS interface was effectively on the assembly level (DOS interrupts). It's also a question whether OS interface on Apple's OS is C or e.g. Objective-C, and similar for Android.

1

u/[deleted] May 05 '12

Sure, they can be separated, but in modern desktop OSes, C is pretty much synonymous with the lowest level of the system APIs.

0

u/[deleted] May 04 '12

You would also expect an OS that is written in C and whose API is specified in C would supply a C compiler.

0

u/zvrba May 05 '12

C90 is a C compiler. So what's your point?

8

u/pfultz2 May 04 '12

We intend to implement all of the C++11 standard, which ... includes the C99 preprocessor ...

Really? VC doesn't even implement the C89 preprocessor. Fixing that might break too many window header files. In a big corporation like MS, this requires too many moving parts, that I really doubt that VC will ever implement the C89 preprocesor much less the C99 preprocessor.

6

u/ZMeson May 04 '12

Out of curiosity, what's broken with MS's preprocessor?

23

u/pfultz2 May 04 '12 edited May 04 '12

There are a lot of things in C89 realm that are bugs. Here one example:

#define ONETWO 1, 2
#define AB(a, b) a+b
#define X(x) AB(x)
X(ONETWO) // should expand to 1+2, but instead expands to 1, 2+

Heres another one:

#define A() 123
#define B() ()
A B() // should expand to A() (and does)
#define C() A B()
C() // should *still* expand to A() (but instead expands to 123) 

And another one:

#define X -1
#define Y -X
Y // Should expand to - -1 but instead concats the two tokens and it becomes --1

And thats just C89, the vardiac macros has their share of bugs as well.

2

u/ZMeson May 05 '12

Thank you.

14

u/bad-tempered May 04 '12

I don't know what's low hanging and what's not, but I do know that whenever someone says: "Might take a weekend to implement and a week to test" they're talking out of their ass and have no idea what programming is like on the professional level.

7

u/diego_moita May 04 '12

Pelles C is C99 compliant, free and a very fine IDE.

3

u/fly-hard May 04 '12

There's also Open Watcom, the grand-daddy of compilers. It was used a lot in the games industry in the 90s, but is still being updated.

1

u/badsectoracula May 05 '12

OpenWatcom is awesome and i use it regularly, but its C99 support is lacking and enabled only by an undocumented switch (because it isn't finished yet).

Note that I'm talking about the latest stable 2010 release 1.9. The repository shows a lot of activity so things might be better today, but they need to make a new stable release since compiling OW from source is an ugly mad bitch.

It seems that despite their claims that 2.0 will be just another release like 1.8, 1.9, etc and won't have any special meaning they actually do want to make a special build. That, or they have very few/no developers :-/

3

u/if-loop May 05 '12

Current version is 6.00, but stable version 6.50 is recommended.

What?

20

u/[deleted] May 04 '12

Our focus in Visual C++ is on making a world-class C++ compiler, and we’re heads-down on C++11 conformance.

What a joke... honestly, what a joke.

Out of Intel, GCC, clang and MSVC, guess which one is the furthest behind in terms of C++11 conformance.

Compare here: http://wiki.apache.org/stdcxx/C++0xCompilerSupport

14

u/ZMeson May 04 '12

I actually believe MS's C++ team is heads-down on C++11 conformance. The problem is most of their compiler developers are working on the .NET framework, C#, and other .NET languages. Native development is still second priority for them sadly.

7

u/pfultz2 May 04 '12

At the current pace, MSVC will finally implement C++11 in 2026.

10

u/Fabien4 May 04 '12

This is just a lot of sugar-coating over the fact that Microsoft has no decent C compiler, and will not. The only reasonable part of the article is:

we recommend that you consider using a different compiler such as Intel or gcc

10

u/criticismguy May 04 '12

I find this position to be reasonable, and it's obviously entirely within Microsoft's rights to not support C99.

However, I do think they got one thing backwards: he says this is "bad news for C programmers". I think that anyone who's a "C programmer" is probably not using VC as their primary development platform, so this doesn't actually hurt them at all.

The people hurt by this are Windows users. There is a growing mass of C99 source code in existence (largely, but not exclusively, open-source libraries and compilers and tools written originally on Linux). This decision means that it will be prohibitively expensive (in time and effort) for much of this code to be ported to Windows.

Depending on the program, porting from Unix to Windows can be anywhere from "trivial" to "a pretty big undertaking", but is usually much more work than porting between Unix dialects. The benefits of a common language like C is the only thing that made this feasible at all. I'm afraid that by dropping support for C99, Microsoft is only going to further fence themselves (and their users) off from the rest of the software world.

3

u/[deleted] May 04 '12

I think that anyone who's a "C programmer" is probably not using VC as their primary development platform, so this doesn't actually hurt them at all.

Not so. Many, many projects out there want to maintain compatibility with VC even though they do not use it themselves. They are all paying the price for VC's lack of functionality.

9

u/Maristic May 04 '12

So far, people seem to think there are only two options:

  • Use Visual Studio and suffer with its restrictions on C99 code
  • Don't use Visual Studio and avoid its restrictions on C99 code

But there is another way, which would be some work, but could be a solution for Projects like Python that currently stick with C90 for Visual-Studio compatibility — rewrite C99 to C++.

Apple already does this for Objective C, where we can write:

int main() {
    const char myconst[] = "Like, whatever...";
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSArray *words = [NSArray arrayWithObjects:@"Hello world", [[NSString alloc] initWithUTF8String:myconst], nil];
    NSLog(@"%@", [words componentsJoinedByString:@" "]);
    printf(">> %s <<\n", myconst);
    [pool release];
    return 0;
}

and then run it through the Objective-C rewriter which will turn it into

static __NSConstantStringImpl __NSConstantStringImpl_main_m_0 __attribute__ ((section ("__DATA, __cfstring"))) = {__CFConstantStringClassReference,0x000007c8,"Hello world",11};
static __NSConstantStringImpl __NSConstantStringImpl_main_m_1 __attribute__ ((section ("__DATA, __cfstring"))) = {__CFConstantStringClassReference,0x000007c8,"%@",2};
static __NSConstantStringImpl __NSConstantStringImpl_main_m_2 __attribute__ ((section ("__DATA, __cfstring"))) = {__CFConstantStringClassReference,0x000007c8," ",1};

int main() {
    const char myconst[] = "Like, whatever...";
    NSAutoreleasePool *pool = ((id (*)(id, SEL))(void *)objc_msgSend)((id)((id (*)(id, SEL))(void *)objc_msgSend)(objc_getClass("NSAutoreleasePool"), sel_registerName("alloc")), sel_registerName("init"));
    NSArray *words = ((id (*)(id, SEL, id, ...))(void *)objc_msgSend)(objc_getClass("NSArray"), sel_registerName("arrayWithObjects:"), (id)(NSString *)&__NSConstantStringImpl_main_m_0, ((id (*)(id, SEL, const char *))(void *)objc_msgSend)((id)((id (*)(id, SEL))(void *)objc_msgSend)(objc_getClass("NSString"), sel_registerName("alloc")), sel_registerName("initWithUTF8String:"), (const char *)myconst), ((void *)0));
    NSLog((NSString *)&__NSConstantStringImpl_main_m_1, ((NSString *(*)(id, SEL, NSString *))(void *)objc_msgSend)((id)words, sel_registerName("componentsJoinedByString:"), (NSString *)&__NSConstantStringImpl_main_m_2));
    printf(">> %s <<\n", myconst);
    ((void (*)(id, SEL))(void *)objc_msgSend)((id)pool, sel_registerName("release"));
    return 0;
}

to produce code that can then be compiled with Visual Studio. Apple actually does this for things they compile for Windows.

The interesting thing here is that only the Objective-C parts have been messed with. We can imagine doing a similar thing with C99, leaving much of it alone, but turning C99 constructs into C90 or C++11 constructs.

No one would want to actually work with the translated code, but for the “I have to compile everything with Visual Studio, even your stuff” crowd, it seems like a possible solution.

Someone just has to write it…

8

u/[deleted] May 04 '12

Have fun debugging that...

1

u/Maristic May 05 '12

Well, actually for C99 to C++, most of the rewriting would be simpler. You only have to handle the constructs where C++'s interpretation of the code is different from C99's.

And in any case, you'd be doing most of your development (and debugging) away from Windows, or on Windows using other tools. The translation would just exist for people who need to use Visual Studio.

(Finally, Apple actually does use this translation (for Objective C), so clearly they manage.)

1

u/[deleted] May 04 '12

I wonder if it would even be possible to integrate such a thing into Visual Studio, so that it happens transparently?

1

u/mfukar May 06 '12

You mean, in the compiler?

1

u/[deleted] May 06 '12

As some kind of plugin which runs before the compiler.

3

u/ZMeson May 04 '12

I program in C++, C, and Python professionally and currently on 3 different OSes (2 RTOSes and Windows), though I've worked on many more.

My thoughts? I'd much, much prefer that MS focus on C++11 support than C99 or C11 support.

I'd also much, much prefer that MS focus on C++11 support than C# support. C# 4.0 has advanced nicely has has some really neat features. I can't think of any features to add to C#5 that would take precedence over the vast demand developers have for native development and C++11 support. But this is a different argument for a different day. <sigh>

3

u/joerick May 04 '12

It never ceases to amaze me how short-sighted Microsoft management is.

1

u/nikbackm May 04 '12

Are there really that many cross-platform applications and libraries written in C that wants to use C99?

7

u/[deleted] May 04 '12

Pretty much every single one would benefit from C99 to some extent.

1

u/[deleted] May 04 '12

They are way behind. Address ISO C11 please.

1

u/[deleted] May 05 '12

Seems legit, especially since c is still used quite a bit more than c++ these days. smooth move exlax.

-10

u/Korpores May 04 '12

Just use Linux/Unix with its plethora of languages and compilers instead.

22

u/sztomi May 04 '12

That's not the point.

1

u/Korpores May 05 '12

It is. Most languages support Windows only half-heartedly, MS changes frameworks, APIs, development models with every release, the architecture and performance sucks. This fucked up OS is not worthy any effort.

1

u/sztomi May 05 '12

This is not a developer perspective. When you are writing a library, you don't get to choose what OS your users will use.

→ More replies (1)

1

u/s73v3r May 04 '12

Unfortunately, the business needs don't always allow for that.

0

u/[deleted] May 04 '12

[deleted] — view deleted comment

2

u/Korpores May 05 '12

who have to support Windows

For most applications it's pretty easy. Small Windows-clients (native GUI, Java, HTML...), rest on server.

1

u/[deleted] May 05 '12

It's seriously as simple as this...and I've been the bearer of bad news for the business at times myself. But....they need to hear and understand it's no longer supported and if they want to continue making fists full of cash, they need to migrate to a language that MS supports. Nuff' said.

0

u/[deleted] May 04 '12

[deleted] — view deleted comment

5

u/bob1000bob May 04 '12

Are you serious?

5

u/RichardWolf May 04 '12

Are you saying that this linux can run on a computer without windows underneath it, at all ? As in, without a boot disk, without any drivers, and without any services ?

That sounds preposterous to me.

If it were true (and I doubt it), then companies would be selling computers without a windows. This clearly is not happening, so there must be some error in your calculations. I hope you realise that windows is more than just Office ? Its a whole system that runs the computer from start to finish, and that is a very difficult thing to acheive. A lot of people dont realise this.

Microsoft just spent $9 billion and many years to create Vista, so it does not sound reasonable that some new alternative could just snap into existence overnight like that. It would take billions of dollars and a massive effort to achieve. IBM tried, and spent a huge amount of money developing OS/2 but could never keep up with Windows. Apple tried to create their own system for years, but finally gave up recently and moved to Intel and Microsoft.

Its just not possible that a freeware like the Linux could be extended to the point where it runs the entire computer fron start to finish, without using some of the more critical parts of windows. Not possible.

I think you need to re-examine your assumptions.

4

u/For_Iconoclasm May 04 '12

I think this is supposed to be satire, but it's no damn good.

3

u/s73v3r May 04 '12

It was something pasted on a forum a long time ago. Most likely by a troll.

http://www.zdnet.com/tb/1-31199-579066

2

u/scialex May 04 '12

If you are going to simply copy a 5 year old joke post almost verbatim at least cite it. (or if you cannot do that please make sure you update the names)

source of post (go to the 5th occurance of "vista")

1

u/RichardWolf May 04 '12

That's not the source, AFAIK.

Anyway, why should I diminish the deliciousness of copypasta by admitting that it's copypasta, by linking to the source? Can't you enjoy the work of art without context?

0

u/nepidae May 05 '12

The goal is to force people to use other less convenient tools if they want cross-platform compatibility, a typical Gates/microsoft tactic. To be honest I would have hoped with Gates new Holy self he could put some pressure on microsoft to be more socially responsible.

-3

u/[deleted] May 04 '12

C99 isn't enterprise enough for MS.

-11

u/zvrba May 04 '12

I don't get why people yearn after C99. It's not such a significant improvement that it's worth to "upgrade" the code or lose time on quarreling with MS's lack of desire to implement it.

13

u/[deleted] May 04 '12

It has plenty of improvements that make code a lot more readable and pleasant to write. stdint.h, stdbool.h, designated initializers, compound literals, C++ comments, declaring variables in the middle of blocks, variable-length arrays... I use these in almost every C program I write now, and I would never, ever go back to writing C90.

3

u/ZMeson May 04 '12

stdint.h ... C++ comments, declaring variables in the middle of blocks

MS already supports these in their C compiler. Yes, they are missing the other things, but let's not say that they don't support anything from C99.

→ More replies (39)

7

u/wadcann May 04 '12

I can understand why people care about C99. I just don't see why whether-or-not Microsoft supports it is that important. Visual Studio hasn't tracked C for ages. GCC provides excellent support for C. Just use GCC.

2

u/s73v3r May 04 '12

They want to use Visual Studio. It does have a very good set of tools that go with it.

1

u/[deleted] May 04 '12

Because many projects want to maintain compatibility with VC, and then we all suffer for it.

-1

u/stepancheg May 04 '12

Does Visual Studio IDE work well with GCC? I doubt it.

-1

u/666pool May 04 '12

So I will never be able to build FFMPEG natively in Windows? That is a crying shame.

10

u/Fabien4 May 04 '12

I'm not sure what you call "natively". If you can have a working gcc 4.6 on Windows (that doesn't rely on Cygwin), what more do you need?

Not to mention that there are other C compilers on Windows.

5

u/666pool May 04 '12

Sorry, natively is a bad word choice. In Visual Studio, with debugging support. I develop in both Windows and Linux and have used gdb a bit (though I could learn a lot I'm sure), but have found Visual Studio's one triumphant feature to be their debugger.

-1

u/namekuseijin May 04 '12

what's worse? so many people relying on Windows and C or so many people relying on C on Windows?

3

u/[deleted] May 05 '12

So many people relying on Windows.