473,770 Members | 5,426 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1622
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/Prlj9GScRAh95AJ 0Y6x4RQeTSm448e AphnfcBf9AFdQCf Wi54
YoxtOIudDOzQvcV amlwNCE0=
=S/1k
-----END PGP SIGNATURE-----
Jul 22 '05 #4
"fabio de francesco" <fm**@tiscali.i t> wrote in message
news:ba******** *************** ***@posting.goo gle.com...
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******@spaml ess.rochester.r r.com> wrote in message news:<K5******* *********@twist er.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*******@jans son.net> wrote in message news:<Pi******* *************** *********@otaku .freeshell.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
2068
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 documentation would be appreciated. Here is some background information about what I'm doing: I have written a large body of code that makes extensive use of mutexes. Most of my code is portable, except for the mutexes, which are platform specific. ...
3
2647
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. Behavior would be completely different on operating systems (Windows, for example) that support wide-character names, than on systems which don't (POSIX). Providing functionality that appears to provide portability but in fact
21
1930
by: asm | last post by:
Hi All, Like typdef, does C have further support for portability? Thanks, ASM
93
3683
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 source code and recompile) is a myth started 20-30 years ago when world consisted of UNIX systems. Well, world does not consist of UNIX systems anymore, but there are 100s of different systems running in cell-phones, DVD players, game consoles...
93
4006
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 so that it will compile in all old and broken compilers, preferably in such a fashion that it can be moved with no effort from the embedded system in the coffe machine to the 64 bit processor in your desktop.
239
10309
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 users request are a part of the OpenSource community. Many if not most of those applications strongly require the presence of the GNU compiling suite to work properly. My assumption is that this is due to the author/s creating the applications...
10
3823
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 application that the code be speed optimized ) I use reinterpret_cast to alias a block of chars read in from disc as a block of integer "words". My existing code (see simplified code below) appears to work well enough on the platforms available to me,...
0
9595
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9432
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10232
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8891
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6682
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2822
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.