[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

Interesting G++ (GNU's C++) incompatabilities

These are only the ones that jumped out at me as interesting.  There
are lots more.

AT&T C++ code will not link correctly with G++ code!!!!  The name
mangling schemes are different and the calling conventions (e.g. use
of stack) is different.  THIS IS A BIG DEAL.

If you want local variables to not get screwed by setjmp/longjmp, the
variables in question must be declared "volatile".  This is an
improvement over most platforms, where this is broken and there is no
known work-arounds.  Heh informs me that this breaks on the Mac, so we
should probably create a "VOLATILE" macro in compatc.h that expands
appropriately on each platform.  The translator already seems to do
the correct thing if you put "VOLATILE" inside a type declaration in
the natural place.

In order to simplify the grammer to LALR(1), they've turned off some
syntactic cases.  But the effect of each case can be had with a
different syntax.  (No big deal)  They claim that the current C++
syntax *cannot* be parsed with an LALR(1) parser, so: Roland,
congratulations on doing the impossible!

neither -p nor -pg are currently supported.  This seems to mean that
G++ cannot be profiled.

They've also implemented lots of extensions which we should ignore.
The neat ones are:

Wrappers, which are their way of reifying a function call/message send
so they can do the things we do with "PROXY:".  I suspect their's is
significantly more space efficient :-)

You can put statements and declarations inside expressions.  This will
be familiar to old Lisp hackers.  Note that if C had this feature,
cfront would've had a MUCH easier time with inline functions.

You can get the type of an expression with "typeof" (analogous to
"sizeof").  This is really neat inside macros.

variable length automatic (stack-based) arrays.

One can declare that certain functions (e.g. "abort()") never return.
This helps avoid spurious warnings.

Global register variables!  Wow!  (I'm serious)  Unfortunately, the
caveats on using them safely are quite burdensome.

One can specify a range in a case label.

Coming up:  Interesting things from the new C++ Reference manual