9

Often I read of some software cutting out some C++ features in order to be compliant with poor/old/exotic C++ compilers.

This one is just the last one I got into: Box2D isn't using namespaces because they need to support:

poor C++ compilers where namespace support can be spotty

A bigger example I can think of is Qt, which is relying upon MOC, is limiting template usage a lot and is avoiding templates (well, this is at least true for Qt3 and previous versions, Qt4 is mostly doing that to keep to their conventions).


I'm wondering what compilers are that poor?
There are lots of C++ compilers out there (I never heard of most of them), but I would hope that all of them are supporting most common(/simple?) C++ features like namespaces (unless they're dead); isn't this the case?

What are the most unsupported features?
I can easily expect the lack of external templates, maybe template partial specialization and similar features. At most even RTTI or exceptions, but I would have never suspected of namespaces.

tshepang
  • 12,111
  • 21
  • 91
  • 136
peoro
  • 25,562
  • 20
  • 98
  • 150
  • 2
    Hmm. Box2D apparently "began life" in early 2006. That sounds on the late side to be avoiding namespaces. But Qt3 dates from a time when there was no decent Windows C++ compiler, and its momentum has carried it since. – aschepler Dec 28 '10 at 21:15
  • 2
    One might note that QT's MOC (Meta Object Compiler) really has nothing to do with have or have-not of one C++ feature or the other. I always viewed it as a (useful) add-on feature that makes programming with Qt simpler than trying to implement its feature set via pure C++. – Martin Ba Dec 28 '10 at 21:21
  • @Martin: as far as I know with C++03 it's relatively simple to implement almost everything MOC is used for, especially the signal/slot mechanism (see boost.signal) which I think is the most important feature for which MOC has been created. – peoro Dec 28 '10 at 21:28
  • @Martin: Parts of what MOC does/did are definitely traces of workarounds for noncompliant compilers, though. In particular, Qt3's `QObject::isA()` is clunkier than `dynamic_cast` (and Qt3 used it along with `reinterpret_cast` to "cast down"). – aschepler Dec 28 '10 at 21:33

7 Answers7

8

In my experience, people are just scared of new things and especially things that broke on them once, 20 decades ago. There's no valid reason against using namespaces in anything written during this century.

If you're looking for things to toss out though, if you happened to be targeting windows not too long ago you had to do more than just toss features out of C++ and not use them, you had to use different syntax. Templates come to mind as one of the worse supported features in VC. They've gotten much better but still fail sometimes.

Another one that is not supported by that particular compiler (STILL!) is overloading virtual functions to return derived type pointers to the types the base version returned when using MI. VC just plain freaks out and you end up having to do virtual_xxx() and providing non-virtual "xxx()" functions to replicate the standard behavior.

user229044
  • 232,980
  • 40
  • 330
  • 338
Edward Strange
  • 40,307
  • 7
  • 73
  • 125
4

What are the most unsupported features?

Let's abstract away export, which, sadly, was an experiment that failed. Then, by count of compiler users this is probably two-phase lookup, which Visual C++ still doesn't properly implement. And VC has a lot of users.

sbi
  • 219,715
  • 46
  • 258
  • 445
2

Basically anything that was added as part of the standardization process in C++98. That is:

  • Templates (Not just partial specialization -- I mean all templates)
  • Exceptions (Often because this one requires runtime support/overhead -- they're often not available on things like microcontrollers)
  • Namespaces
  • RTTI

If you go even older, you can add

  • Most everything in the standard library.

Several old compilers are just plain bad; OTOH I would strongly not recommend worrying about them. There are already several good and freely available reasonably standards compliant compilers available for pretty much every platform of which I am aware (mostly via G++).

Billy ONeal
  • 104,103
  • 58
  • 317
  • 552
  • 2
    Hell, really? Which compilers nowadays don't properly support namespaces, templates, and the little RTTI C++ has?? Is there _anything_ relevant in that list of compilers? I seriously doubt it. – sbi Dec 28 '10 at 21:14
  • @sbi: I was assuming the OP was talking about older/obscure compilers as most modern compilers support pretty much everything in C++03 pretty well. – Billy ONeal Dec 28 '10 at 21:17
  • 2
    Modern software development shouldn't cater to those ancient compilers. You can't even call them C++ anymore. Now that the language is standardized they're all non-conformant and implement a language LIKE C++ but not C++. Modern design methods pretty much REQUIRE a conformant compiler and so by limiting yourself to supporting those that don't you're seriously hindered in your use of a lot of very powerful tools. – Edward Strange Dec 28 '10 at 21:20
  • @Noah: That's what I said in my last paragraph. – Billy ONeal Dec 28 '10 at 21:22
  • 1
    How old is old? I think almost any compiler released in this century supports listed features reasonably well. – Gene Bushuyev Dec 28 '10 at 21:31
  • @Gene: The OP is specifically talking about compilers which don't support *namespaces*. That puts one in the pretty old territory. – Billy ONeal Dec 28 '10 at 21:32
1

Namespaces have been around forever. Some of the darker places in templates, maybe. But namespaces? No way. Even with templates, the vast, vast majority of usage scenarios are fine. Some compilers aren't perfect (they're software), but flat out not supporting a C++03 feature that isn't export? That just doesn't happen. Most compilers extend the language, not reduce it, and are moving to support C++0x.

RTTI and exceptions are often accused of poorly efficient implementations, but not poor implementation conformance.

Puppy
  • 144,682
  • 38
  • 256
  • 465
1

If you are programming in the main stream with a main stream compiler then usually you find everything in the C++03 standard supported (except export as mentioned by sbi (but then again nobody used the feature (as it was not supported)). The further from the main stream the compiler is the less features usually (but they are all moving forward (some more slowly than others))

Its only when you get to less used hardware that has its own proprietary compiler that support for features start to dwindle.

The main example would be mobile devices and their associated compilers (though because of their popularity in the main stream in recent years these compilers are getting updated more quickly than before).

A secondary example would by SOC devices. There compilers are so specific that they are usually in house compilers and only get as much work on them as the SOC company can afford and as a result tend to lag a long way (or at least further) behind other compilers.

Martin York
  • 257,169
  • 86
  • 333
  • 562
  • No way Martin! Get real. I am using the latest OSX Snow Leopard and the gcc that comes with it doesn't support any C++03 features at all. And since I have only wireless internet I can't upgrade it, even if Apple bothers to (which it may not). – Yttrill Dec 28 '10 at 22:07
  • 2
    @Yttrill: if I recall correctly, Apple uses GCC 4.2.1, which [has been released the 18th July 2007](http://gcc.gnu.org/gcc-4.2/). Unless you're using an old version of GCC 3, released around 2000 (which I doubt about), I'm pretty sure your GCC support a lots of features of C++03. Maybe you're talking about C++0x? – peoro Dec 28 '10 at 22:13
  • 2
    @Yttrill: You must be confusing standards. Namespaces, Templates, RTTI, and Exceptions are available pretty much everywhere, including OSX. – Billy ONeal Dec 28 '10 at 22:35
  • @Yttrill: On my OS-X system here 10.6.5. It uses gcc 4.2.1 (from X-Code) it supports all the C++03 features (Namespace/Exceptions/etc/etc). It does not support C++0x features though which is a pain. But I am sure apple will solve that real soon (though they will probably shift compiler from what I hear). You can always download the gcc source and build your own version (it does not take that long even over wireless aprox 40 min). – Martin York Dec 29 '10 at 00:18
1

Value Initialization (C++03 feature) is not properly implemented in MSVC++.

Community
  • 1
  • 1
Prasoon Saurav
  • 91,295
  • 49
  • 239
  • 345
0

Qt doesn't use templates much because it is older than templates.

Joshua
  • 40,822
  • 8
  • 72
  • 132
  • This is true, but it really doesn't answer the question. – Billy ONeal Dec 28 '10 at 21:10
  • This should probably be a comment to the question. – sbi Dec 28 '10 at 21:11
  • 4
    Qt has more issues than that. A Q_OBJECT class can't be a template either, the MOC will vomit. One of the biggest problems with Qt, an otherwise great library, is the use of "extensions" that actually break the language in order to turn C++ into Python. – Edward Strange Dec 28 '10 at 21:11