How portable is C++ today

M

Metaosp

Hi,

When it comes to code portability, most people would think C is a better
choice then C++. That was probably true 5 or 10 years ago, but how
about today? Are there still many platforms or devices that have no
good C++ compiler? C++ offers a lot more then C, would you use it to
build a new cross-platform project that will support a wide range of
platforms, say from handheld devices to multi-nodes servers?
 
M

Moonlit

Hi,

Standard C++ is very portable. I develop mostly for unix (g++ version > 3.)
like systems but I never have a problem compiling the code (MS-VC++ 2003 and
later) on windows. However as soon as you start to use system specific stuff
threading/mutexes/micro timers or windowing systems than you likely do have
a small or large portability problem. It would be great if C++ (and C) would
add multi threading and micro timers to the standard libraries since I think
a lot of modern systems need or use them in some way.

--


Regards, Ron AF Greve

http://moonlit.xs4all.nl
 
D

Default User

loufoque said:
Metaosp a écrit :


Tools exist to convert C++ code to C.

Convert? Not really. There are some compilers that will compile to C.
Those don't usually produce any kind of C code that can be used by
humans successfully.



Brian
 
L

loufoque

Default User a écrit :
Those don't usually produce any kind of C code that can be used by
humans successfully.

Indeed, put that's not the point.
The point is to compile C++ code on a platform that only has a C compiler.
 
H

heinz

It would be great if C++ (and C) would add multi threading
and micro timers to the standard libraries since I think
a lot of modern systems need or use them in some way.

That would have been really, really nice 20 years ago, but today we
really need direct keyboard control (rather than echo'd input streams)
and also graphical display (rather than typewriter like text out) as
well.

A truly portable C++ application can be little other than a crude
command line tool. This isn't the kind of application your typical user
runs today. To realize portability with C++, it is up to the developer
to partition projects into portable and non-portable sections and use
things in the standard whenever there is a choice versus platform
specific API's or compiler extensions. Tuning the architecture to
maximize portability is not free and takes time, but it is an
investment that pays dividends in the end.
 
M

Moonlit

Hi,

You assume that every program has a user interface. Actually the programs I
usually write don't. And still then, I can use a lot of the classes I write
in windows application. Sockets, logging etc. these are all common amongst
unices and ms-windows.

And we do need multithreading, microtimers and the lot in today's windows
applications and daemons etc.. Multithreading isn't exactly a technology of
twenty yeears ago it is something that get's used more and more (for
isnstance to separate the event-handling thread (that handles gui messages)
and doing heavy duty stuff in the background ).



Regards, Ron AF Greve

http://moonlit.xs4all.nl
 
C

Chameleon

Moonlit said:
Hi,

Standard C++ is very portable. I develop mostly for unix (g++ version > 3.)
like systems but I never have a problem compiling the code (MS-VC++ 2003 and
later) on windows. However as soon as you start to use system specific stuff
threading/mutexes/micro timers or windowing systems than you likely do have
a small or large portability problem.

It would be great if C++ (and C) would
add multi threading and micro timers to the standard libraries since I think
a lot of modern systems need or use them in some way.


I believe, companies must agree to a third-party API libraries which
must be implemented in all OS platforms. (like OpenGL in 3d graphics, or
MIDP 2.0 on mobile phones)

However, a compiler for an 8-bit microcontroller and an OS for x86
processors cannot have the same API.
 
C

Chameleon

loufoque said:
Metaosp a écrit :


Tools exist to convert C++ code to C.

Wrong. Not in human readable form.

btw, this decreases optimization from C++ compiler.
 
M

Michiel.Salters

Rolf said:
And what exactly is the difference?

Expectations. I'd expect a converter to convert // to /* */ . I'd
expect a compiler
to strip them outright. Same goes for every other preprocessor entity.
Since
that includes headers, the output of the compiler could be usable on
only that
precise machine, with precisely the one C compiler installed there.

HTH,
Michiel Salters
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top