T
Tomás Ó hÉilidhe
I've been writing mostly C code for the last year or so (rather than
C++), and in writing C code I always make it fully portable, allowing for
9-Bit bytes, allowing for padding within integer types, allowing for null
pointers whose bit representation isn't all zeroes, allowing for either
of the three number systems, allowing for character sets other than ASCII
(e.g. 'A' isn't necessarily == 65).
The current project I'm working on is evolving quite a bit though...
and I think I'm being pushed to the edge to switch to C++. First thing I
could do with is namespaces, but also as soon as I get the go-ahead to
use classes I'll be restructuring the code altogether.
Anyway, I'd like to ask if C++ has as wide a variety of
implementations as does C? I mean you'll find a C implementation that has
9-Bit bytes, or 64-Bit bytes, or one that has padding in its integer
types. But what about C++? Is there variety?
The reason I ask is that if there isn't much variety in C++, then I
might switch to making my code less flexible. For instance I might assume
that an unsigned long has no padding and then go on to use it to
manipulate sizeof(unsigned long) bytes at a time.
The program I'm currently writing is mostly comprised of algorithms
that can be coded fully-portably in C, but now that I've decided to make
an interface for it (including a GUI), it's getting a bit more
complicated. I'd switch to C++ in a heartbeat but I want to maintain as
great portability as I can (and of course I'll lose a good chunk of
portability if I move to C++).
Would it be out of the question do you think to leave the algorithmic
code as C, and then write the interface code as C++... ? That way I could
still make commandline programs out of the algorithms.
One thing I won't be doing ever though is assuming 8-Bit bytes or
assuming a 32 or 64-Bit system, because in ten years we could be using
systems with 16-Bit bytes.
C++), and in writing C code I always make it fully portable, allowing for
9-Bit bytes, allowing for padding within integer types, allowing for null
pointers whose bit representation isn't all zeroes, allowing for either
of the three number systems, allowing for character sets other than ASCII
(e.g. 'A' isn't necessarily == 65).
The current project I'm working on is evolving quite a bit though...
and I think I'm being pushed to the edge to switch to C++. First thing I
could do with is namespaces, but also as soon as I get the go-ahead to
use classes I'll be restructuring the code altogether.
Anyway, I'd like to ask if C++ has as wide a variety of
implementations as does C? I mean you'll find a C implementation that has
9-Bit bytes, or 64-Bit bytes, or one that has padding in its integer
types. But what about C++? Is there variety?
The reason I ask is that if there isn't much variety in C++, then I
might switch to making my code less flexible. For instance I might assume
that an unsigned long has no padding and then go on to use it to
manipulate sizeof(unsigned long) bytes at a time.
The program I'm currently writing is mostly comprised of algorithms
that can be coded fully-portably in C, but now that I've decided to make
an interface for it (including a GUI), it's getting a bit more
complicated. I'd switch to C++ in a heartbeat but I want to maintain as
great portability as I can (and of course I'll lose a good chunk of
portability if I move to C++).
Would it be out of the question do you think to leave the algorithmic
code as C, and then write the interface code as C++... ? That way I could
still make commandline programs out of the algorithms.
One thing I won't be doing ever though is assuming 8-Bit bytes or
assuming a 32 or 64-Bit system, because in ten years we could be using
systems with 16-Bit bytes.