public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Allow C++ or C99 in sim/*?
@ 2003-08-02  0:16 Andrew Cagney
  2003-08-02  0:43 ` Daniel Jacobowitz
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Andrew Cagney @ 2003-08-02  0:16 UTC (permalink / raw)
  To: gdb

Hello,

Back in '95ish, I adopted ISO C 90 as its programming language for PSIM. 
  My decision was based on two assumptions: a C++ compiler would be more 
buggy than C; the C language would be easier for a compiler to optimize 
than C++; no one in their right mind still used K&R C.  Over time, the 
ISO C 90 assumption was gradually extended to other simulators (via 
sim/igen and sim/common) and that led to the sim/ directory requiring 
ISO C.  This was all well before gdb/ adopted ISO C 90.  History has 
shown this to be a good decision.

Now, many years later, I think its time to revisit this:

Should the simulator directories allow more modern languages?  I can see 
several options:

- C99 which would allow C++ comments:
	// a comment
and declarations anywhere:
	foo (); int i; bar ()
and access to int32 et.al. types.  What else?

- C++ which would also allow access to objects and (ulgh?) templates 
(replacement for the sim-endian macro stuff?)

- Oh what the heck, Java and gcj ...

C99 should be a done deal.  While I hate C++, making GDB developers 
debug C++ code would be a good thing (TM), and there are a few chunks of 
the simulator code that really shouldn't be C.  Java would be, well, 
interesting.

Thoughts?  Coding standards?

Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: Allow C++ or C99 in sim/*?
@ 2003-08-02  1:11 Michael Elizabeth Chastain
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Elizabeth Chastain @ 2003-08-02  1:11 UTC (permalink / raw)
  To: ac131313, gdb

Not like I work in sim/ anyways ... so all this is from the
peanut gallery.

I like C++ more than C99.

If we go with C99, and actually start using C99 features, we'll get
unhappy users who still have C90 compilers.  And if we tell them "just
use gcc" (which I think is a valid response) then we might as well
go all the way to C++.

My experience with C++ is that it makes some maintenance tasks easier.
If there is a crappy class, it's easier to rip out / rewrite a class in
C++ than it is to do the equivalent in C.

We would get massive dogfood benefits from writing in C++.  That would
be the major benefit.

For a C++ coding standard, there are several views.  The official Bjarne
Stroustrup view is to use the whole freakin' language because every
feature in the language is there for a good reason.  For the purpose
of eating dogfood, that is a reasonable thing.

My personal view is that I stay away from templates and rtti because
they require link time support, thus are less portable.  Also I stay
away from namespaces because they confuse gdb.  That would be a reason
*for* using namespaces for us!  And I eschew exceptions because I don't
like the way they were glommed onto the language as an afterthought.

gcc 2.95.3 has a usable C++ compiler, although it's incomplete in many
areas.

Michael C

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-08-05  4:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-02  0:16 Allow C++ or C99 in sim/*? Andrew Cagney
2003-08-02  0:43 ` Daniel Jacobowitz
2003-08-02  0:47 ` David Carlton
     [not found] ` <mailpost.1059783391.21631@news-sj1-1>
2003-08-02  1:30   ` cgd
2003-08-05  4:25     ` Andrew Cagney
2003-08-05  4:27       ` Daniel Jacobowitz
2003-08-02  1:11 Michael Elizabeth Chastain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).