473,408 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Portability, where?

Hi,

I'm not a professional programmer, but I've been writing C/C++ and Ada
programs for a few years on GNU/Linux without ever concerning on
standards and portability to other OSs.

I've always noted that when I write code I must use lots of platform
specific system calls (POSIX and X/OPEN). Often I found myself using
threads and concurrent processes with some sort of IPC. Some time I
need some socket API. When I just want to open a file, making the
function fail if the file exist I have to use the low-level open()
with O_EXCL. Many more examples like these can be showed.

What I would like to ask is:

1) Is portability and adhesion to the standards a real concern for the
people in this group?

2) Is it possible to write real code without breaking portability and
adhesion to the standards?

3) What kind of choices do people that write code as a job take to
deal with these issues?

Ciao,

Fabio De Francesco
Jul 22 '05 #1
7 1595
On Mon, 5 Jul 2004, fabio de francesco wrote:
1) Is portability and adhesion to the standards a real concern for the
people in this group?
Yes. This group is about *the* ISO/ANSI C++ Standard.
2) Is it possible to write real code without breaking portability and
adhesion to the standards?
I believe so. I have written a lot of code that follows the standard and
that code actually compiles fine for a lot of platforms. Further, this
have been *real* code, used in *reality*.
3) What kind of choices do people that write code as a job take to
deal with these issues?


I often design code to follow the C++ standard and use abstract base
classes for classes that later perhaps must be specialized due to some
platform specific issue.

Regards,
Peter Jansson
http://jansson.net/

Jul 22 '05 #2
Peter Jansson wrote:

On Mon, 5 Jul 2004, fabio de francesco wrote:
1) Is portability and adhesion to the standards a real concern for the
people in this group?


Yes. This group is about *the* ISO/ANSI C++ Standard.


<nitpick>

Actually, comp.lang.c++ is about the usage of the _language_ as defined by the
standard.

The group about the standard is comp.std.c++

</nitpick>
Jul 22 '05 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

fabio de francesco wrote:
Hi,

I'm not a professional programmer, but I've been writing C/C++ and Ada
programs for a few years on GNU/Linux without ever concerning on
standards and portability to other OSs.

I've always noted that when I write code I must use lots of platform
specific system calls (POSIX and X/OPEN). Often I found myself using
threads and concurrent processes with some sort of IPC. Some time I
need some socket API. When I just want to open a file, making the
function fail if the file exist I have to use the low-level open()
with O_EXCL. Many more examples like these can be showed.

What I would like to ask is:

1) Is portability and adhesion to the standards a real concern for the
people in this group?

2) Is it possible to write real code without breaking portability and
adhesion to the standards? It looks like the portability issues you are looking at aren't related
to the language (yet), such as, thread initialization, signals,
sockets, and low level file IO operations.

While most of these can be partially addressed in add on libraries such
as Boost, they aren't yet part of the C++ standard. That said, since you
are already familliar with the Linux environment, if you are really
interested in portability, you might take a gander at GNU's
Autoconf/Automake/libtool utilities. These tools are designed with
portability in mind and make the tack of code distribution much easier.
3) What kind of choices do people that write code as a job take to
deal with these issues?

Ciao,

Fabio De Francesco


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFA6coFoo/Prlj9GScRAh95AJ0Y6x4RQeTSm448eAphnfcBf9AFdQCfWi54
YoxtOIudDOzQvcVamlwNCE0=
=S/1k
-----END PGP SIGNATURE-----
Jul 22 '05 #4
"fabio de francesco" <fm**@tiscali.it> wrote in message
news:ba**************************@posting.google.c om...
Hi,

I'm not a professional programmer, but I've been writing C/C++ and Ada
programs for a few years on GNU/Linux without ever concerning on
standards and portability to other OSs.

I've always noted that when I write code I must use lots of platform
specific system calls (POSIX and X/OPEN). Often I found myself using
threads and concurrent processes with some sort of IPC. Some time I
need some socket API. When I just want to open a file, making the
function fail if the file exist I have to use the low-level open()
with O_EXCL. Many more examples like these can be showed.

What I would like to ask is:

1) Is portability and adhesion to the standards a real concern for the
people in this group?
Yes.

2) Is it possible to write real code without breaking portability and
adhesion to the standards?
Well, I certainly try. For instance, I have some software which must load a
shared library by name. Of course this is operating system dependent, but I
was able to minimize the dependence by encapsulating the details using a
"pointer to implementation" pattern. Using this technique the software
(which has hundreds of files total) has only two or three small files which
include windows.h.

3) What kind of choices do people that write code as a job take to
deal with these issues?
Lately I've been porting my Windows C++ code to Unix even though I don't
particularly need the Unix version. I thought I was writing portable code
before but when I tried porting to Unix I found a lot of problems. Now my
Windows code is more portable and also conforms to the standard better.

The other thing I do is to use Python to write "glue" code. Python is slow
compared to C++ but has excellent portability and supports threads, sockets,
and a whole lot of other things. The fact that Python is ultimately based on
C shows that you can write a single interface that covers a lot of operating
system territory.

Ciao,

Fabio De Francesco


--
Cy
http://home.rochester.rr.com/cyhome/
Jul 22 '05 #5
"Cy Edmunds" <ce******@spamless.rochester.rr.com> wrote in message news:<K5****************@twister.nyroc.rr.com>...
...
Well, I certainly try. For instance, I have some software which must load a
shared library by name. Of course this is operating system dependent, but I
was able to minimize the dependence by encapsulating the details using a
"pointer to implementation" pattern. Using this technique the software
(which has hundreds of files total) has only two or three small files which
include windows.h.
...
The other thing I do is to use Python to write "glue" code. Python is slow
compared to C++ but has excellent portability and supports threads, sockets,
and a whole lot of other things. The fact that Python is ultimately based on
C shows that you can write a single interface that covers a lot of operating
system territory.
Peter Jansson <we*******@jansson.net> wrote in message news:<Pi*******************************@otaku.free shell.org>...
I often design code to follow the C++ standard and use abstract base
classes for classes that later perhaps must be specialized due to some
platform specific issue.


These examples have exactly the kind of informations I need. Please,
some more like them.

Regards,

Fabio De Francesco
Jul 22 '05 #6
On Tue, 6 Jul 2004, fabio de francesco wrote:
These examples have exactly the kind of informations I need. Please,
some more like them.


I could perhaps give you som more examples if you supply more intelligence
into what you are designing or hoping to desing in the future.

Regards,
Peter Jansson
http://jansson.net/
Jul 22 '05 #7
fabio de francesco wrote:
I'm not a professional programmer,
but I've been writing C/C++ and Ada programs for a few years
on GNU/Linux without ever concerning on standards
and portability to other OSs.

I've always noted that, when I write code,
I must use lots of platform specific system calls (POSIX and X/OPEN).
Often, I found myself using threads and concurrent processes
with some sort of IPC. Some time I need some socket API.
When I just want to open a file, making the function fail
if the file exist I have to use the low-level open() with O_EXCL.
Many more examples like these can be showed.

What I would like to ask is:

1) Is portability and adhesion to the standards
a real concern for the people in this group?
Yes.
2) Is it possible to write real code
without breaking portability and adhesion to the standards?
No.
3) What kind of choices do people that write code as a job take
to deal with these issues?


Layering.

In a *layered* design,
platform dependent code is sequestered in libraries separate
from the common portable code. The common portable code
is said to be "built on top of" the underlying platform dependent code
because it invokes platform dependent behavior *only* through
function calls to the platform dependent library functions.
(platform = machine architecture + operating system + C++ compiler).

It is practically impossible
to write useful programs that port everywhere.
A GUI written for your Windows PC probably won't port to you cell phone.
Compliance with the ANSI/ISO C++ standards
has almost nothing to do with portability
and is your *least* important consideration.
The most importand determinant of portability is whether or not
the required *resources* are provided by the target platform.
You must identify all of the possible target platforms and, in practice,
you must build and test your program on each target platform
before you can claim that it will port to it.

The C and C++ computer programming languages are frequently used
instead of assembler to implement the platform dependent code
as well as the common portable code. This code may include
language extensions and invoke behavior which is not defined
by the ANSI/ISO C++ standard as long as the behavior is well defined
for the target platform. For example,
the implementation of the standard library that came with your compiler
will *not* generally port to any other platform. For example,
the device drivers that are used by your operating system
may have been written in C++ but are *not* guaranteed to port
to any other machine architecture.
Jul 22 '05 #8

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

Similar topics

8
by: Ed Fair | last post by:
Hi, I'm a long-time C programmer, I've started making the transition to "real C++" recently. I am puzzled about how to write a factory method. Any suggestions, pointers or references to...
3
by: Jonathan Mcdougall | last post by:
I started using boost's filesystem library a couple of days ago. In its FAQ, it states "Wide-character names would provide an illusion of portability where portability does not in fact exist....
21
by: asm | last post by:
Hi All, Like typdef, does C have further support for portability? Thanks, ASM
93
by: roman ziak | last post by:
I just read couple articles on this group and it keeps amazing me how the portability is used as strong argument for language cleanliness. In my opinion, porting the program (so you just take the...
93
by: jacob navia | last post by:
In this group there is a bunch of people that call themselves 'regulars' that insist in something called "portability". Portability for them means the least common denominator. Write your code...
239
by: Eigenvector | last post by:
My question is more generic, but it involves what I consider ANSI standard C and portability. I happen to be a system admin for multiple platforms and as such a lot of the applications that my...
10
by: Lionel B | last post by:
Greetings, I have some code that is to read unformatted data from disc and interpret it as blocks of unsigned integers. In an attempt to achieve efficiency (it is pretty essential for my...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.