473,513 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How portable is C++ today

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?
--
Metaosp
Feb 25 '06 #1
11 1965
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

"Metaosp" <me*****@gmail.com> wrote in message
news:1140870891.20935.21.camel@jupiter...
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?
--
Metaosp

Feb 25 '06 #2
Metaosp a écrit :
When it comes to code portability, most people would think C is a better
choice then C++.


Tools exist to convert C++ code to C.
Feb 25 '06 #3
loufoque wrote:
Metaosp a écrit :
When it comes to code portability, most people would think C is a
better choice then C++.


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
Feb 25 '06 #4
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.
Feb 25 '06 #5
I've de-top posted this

Moonlit wrote:
"Metaosp" <me*****@gmail.com> wrote in message
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?


Standard C++ is very portable.


I understood (and I'm no expert) that some of the more esoteric
template stuff was not universally supported. For instance this page
from Boost:

http://www.boost.org/status/compiler_status.html
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.


--
Nick Keighley

Feb 25 '06 #6
Default User wrote:
loufoque wrote:
Metaosp a écrit :
> When it comes to code portability, most people would think C is a
> better choice then C++.
Tools exist to convert C++ code to C.


Convert? Not really. There are some compilers that will compile to C.


And what exactly is the difference?
Those don't usually produce any kind of C code that can be used by
humans successfully.


So?

Feb 25 '06 #7
> 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.

Feb 26 '06 #8
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

"heinz" <he********@my-deja.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...
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.

Feb 26 '06 #9
Moonlit wrote:
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.
Feb 26 '06 #10
loufoque wrote:
Metaosp a écrit :
When it comes to code portability, most people would think C is a better
choice then C++.


Tools exist to convert C++ code to C.


Wrong. Not in human readable form.

btw, this decreases optimization from C++ compiler.
Feb 26 '06 #11

Rolf Magnus wrote:
Default User wrote:
loufoque wrote:
Tools exist to convert C++ code to C.


Convert? Not really. There are some compilers that will compile to C.


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

Feb 27 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
1674
by: Martin Vorbrodt | last post by:
Hi there. Is this code portable between platforms? Is it also 100% standard compliant? #include <iostream> using namespace std; class Point { public: enum COORDS { X = 0, Y, Z }; Point(int...
385
16876
by: Xah Lee | last post by:
Jargons of Info Tech industry (A Love of Jargons) Xah Lee, 2002 Feb People in the computing field like to spur the use of spurious jargons. The less educated they are, the more they like...
5
4786
by: Mark Shelor | last post by:
Problem: find a portable way to determine whether a compiler supports the "long long" type of C99. I thought I had this one solved with the following code: #include <limits.h> #ifdef...
7
2061
by: Robert Bachmann | last post by:
Two years I wrote a simple cesar encryption program, it worked but it relied on ASCII. So today I tried to make an portable cesar encryption. Please tell me if the code below is really protable. ...
23
3148
by: Ken Turkowski | last post by:
The construct (void*)(((long)ptr + 3) & ~3) worked well until now to enforce alignment of the pointer to long boundaries. However, now VC++ warns about it, undoubtedly to help things work on 64...
10
3654
by: ibic | last post by:
Just curious: is it possible to recursively list all the directorys/files inside a given directory using standard c i/o library routines only, which can be re-compiled and run on any os supportes c...
131
6021
by: pemo | last post by:
Is C really portable? And, apologies, but this is possibly a little OT? In c.l.c we often see 'not portable' comments, but I wonder just how portable C apps really are. I don't write...
28
2690
by: lovecreatesbeauty | last post by:
On gcc, which version of C standard has the most compliant: -c89, -ansi or c99? For more portable C code, which options should be applied to compilation? Can the following options guarantee the...
69
2569
by: Bill Reid | last post by:
This is how I handle a check that the last character of a text file is a newline: /* checks if newline is last character of text file */ unsigned check_text_file_newline_termination(FILE...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7160
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7537
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7525
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.