473,854 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

code portability

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 with the GNU suite.
Many of the tools requested/required are GNU replacements for make,
configure, the loader, and lastly the C compiler itself. Where I'm going
with this is, has the OpenSource community as a whole committed itself to at
the very least encouraging its contributing members to conform to ANSI
standards of programming?

My concern is that as an admin I am sometimes compelled to port these
applications to multiple platforms running the same OS and as the user
community becomes more and more insistent on OpenSource applications will
gotcha's appear due to lack of portability in coding? I fully realize that
independent developers may or may not conform to standards, but again is it
at least encouraged?

11.32 of the FAQ seemed to at least outline the crux of what I am asking.
If I loaded up my home machine to the gills will all open source compiler
applications (gcc, imake, autoconfig, etc....) would my applications that I
compile and link and load conform?
Aug 1 '06
239 10375
Racaille said:
Richard Heathfield wrote:
> char 8 bits
short 64 bits
int 64 bits
long 64 bits

and at least one implementation does it like that.

which one ?
One of the Cray implementations . I forget which one. Nexus rings a bell, but
I wouldn't swear to it.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Aug 8 '06 #111
"Frederick Gotham" <fg*******@SPAM .comwrote in message
news:O8******** ***********@new s.indigo.ie...
Philip Potter posted:

The people who are arguing that "other people should be able to read your
code" are the very people who have difficulty reading other people's code.
Big deal: I write "char unsigned" instead of "unsigned char"... is it
really that bewildering?
Personally, if I learn that somebody has trouble reading my code, I assume
that it's my fault, not theirs.
At then end of the day, if you have a problem with:

char unsigned const static inline (*const Func(void))[3]

, then you should take it up with the Standards Commitee -- because right
now, it's perfectly legal, and I like it. (And please don't come back with
an argument such as the following is legal:

#define void int
#define main core
#define start {
#define end }

void core()
start
return 0;
end
Why not? It's a perfectly good argument. Legality != readability.

--

Philip Potter

Aug 8 '06 #112
On Tue, 08 Aug 2006 09:05:51 GMT, Frederick Gotham
<fg*******@SPAM .comwrote:
>Keith Thompson posted:
>Ok, so your style is internally consistent, but it's inconsistent with
perhaps 99.73% of other C programmers (I made up that number).


I like my style though.

There's plenty of things I do which most C++ programmers don't do. For
instance, I use "++i" instead of "i++" when I discard the value of the
expression.

There are flaws in the way most programmers do things; my style tries to
improve on this.
Kepp trying - you have a long way to go. First, you have to get up to
their level, then you can start improving things. Don't confuse
"different" with "better."
>
>> char unsigned const static inline (*const Func(void))[3]

Anyone seeing that almost certainly going to spend far more time
wondering why the keywords are in that order and mentally translating
it to a more traditional order than appreciating the esthetics.


If they're only used to reading their own code, then they could do with the
practise of seeing other people's code. Do they brain-freeze when they see:

int const *p

rather than:

const int *p

>As Henry Spencer wrote in "The Ten Commandments for C Programmers",
<http://www.lysator.liu .se/c/ten-commandments.ht ml>:

... thy creativity is better used in solving problems than in
creating beautiful new impediments to understanding.


I make up the rules as I go along. I used to like:

const int *p;

, but now I use:

int const *p;
--
Al Balmer
Sun City, AZ
Aug 8 '06 #113
Al Balmer posted:
First, you have to get up to their level, then you can start improving
things.

Perhaps you'd like to post some of your own code, and I'll point out the
flaws?

--

Frederick Gotham
Aug 8 '06 #114
Frederick Gotham <fg*******@SPAM .comwrites:
Keith Thompson posted:
>Ok, so your style is internally consistent, but it's inconsistent with
perhaps 99.73% of other C programmers (I made up that number).


I like my style though.
Ok. What about anyone else who reads your code?

You can, of course, write anything you like, either in your C code or
on this newsgroup. But if you expect anyone else to read it, or
particularly to maintain it, you would benefit greatly from following
certain conventions that will make what you write easier to read.

Unless you manage to mount a *successful* campaign to change the
generally accepted style, you're just "creating beautiful new
impediments to understanding".
There's plenty of things I do which most C++ programmers don't do. For
instance, I use "++i" instead of "i++" when I discard the value of the
expression.
Most of us here do something most C++ programmer's don't do: we write C.
++i and i++ are equivalent when the value is discarded, and I find
them equally clear. (comp.lang.c++ is down the hall, past the water
cooler, third door on the left.)
There are flaws in the way most programmers do things; my style tries to
improve on this.

>> char unsigned const static inline (*const Func(void))[3]

Anyone seeing that almost certainly going to spend far more time
wondering why the keywords are in that order and mentally translating
it to a more traditional order than appreciating the esthetics.


If they're only used to reading their own code, then they could do with the
practise of seeing other people's code. Do they brain-freeze when they see:

int const *p

rather than:

const int *p
No, that's straightforward enough that my brain doesn't even get
chilly.

How do you feel about this?

char const inline static unsigned (*const Func(void))[3]

Don't you think there's some advantage in having all the keywords in
alphabetical order? 8-)}
I make up the rules as I go along.
[snip]

And that's the problem. If programming is a solitary activity for
you, that's fine. If not, I think you're making a mistake.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Aug 8 '06 #115
Richard Heathfield <in*****@invali d.invalidwrites :
Racaille said:
>Richard Heathfield wrote:
>> char 8 bits
short 64 bits
int 64 bits
long 64 bits

and at least one implementation does it like that.

which one ?

One of the Cray implementations . I forget which one. Nexus rings a bell, but
I wouldn't swear to it.
Cray vector systems. I've seen this on the T90 and J90 (both of which
are more or less obsolete). I'm not sure what the newer vector
systems do.

These systems are optimized for massive floating-point calculations.
The hardware can only directly access 64-bit words; 8-bit bytes are
manipulated in compiler-generated software. (They could have made
ChAR_BIT 64, but that would have created too much incompatibility with
other systems, and with the Unix-based operating systems these things
run.)

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Aug 8 '06 #116
On Tue, 08 Aug 2006 16:44:55 GMT, Frederick Gotham
<fg*******@SPAM .comwrote:
>Al Balmer posted:
>First, you have to get up to their level, then you can start improving
things.


Perhaps you'd like to post some of your own code, and I'll point out the
flaws?
I wouldn't bother, since you and I obviously have very different ideas
as to what constitutes good code.

I'll just say that if you presented the examples you've shown in a
code review here, you'd be told to fix them. If the second review
wasn't drastically improved, there wouldn't be a third.

So, do your own thing, but I hope no one else ever has to deal with
it.

--
Al Balmer
Sun City, AZ
Aug 8 '06 #117
Frederick Gotham <fg*******@SPAM .comwrites:
Philip Potter posted:
>It's almost always better to stick with a coding style that you perceive
as flawed but which everyone is used to, than to use your own style
which (despite any advantage it may offer) nobody is used to and so
nobody can read.


If you're going to be reading other people's code, you need to be used to
variety.

If part of your job is reading other people's code, then you should be good
at it. It takes less than an hour to get used to different word orderings:
[examples snipped]

And that's an hour of my life I'll never get back. I'll expend the
time if it's worth it.
The people who are arguing that "other people should be able to read your
code" are the very people who have difficulty reading other people's code.
Big deal: I write "char unsigned" instead of "unsigned char"... is it
really that bewildering?
It takes a small amount of time to figure it out the first time you
see it, and some more time to figure out why it's being written that
way. If I see "char unsigned" in some random piece of code, I'm not
just going to wonder why it's written that way, I'm also going to
wonder whether it's correct. I know the language allows either order,
but I'm going to have to allow for the possibility that the author
doesn't know what he's doing. I know that "unsigned char" and "char
unsigned" mean the same thing, but how do I know that the author knows
that?
At then end of the day, if you have a problem with:

char unsigned const static inline (*const Func(void))[3]

, then you should take it up with the Standards Commitee -- because right
now, it's perfectly legal, and I like it.
No, I'm taking it up with you, because you wrote it.
(And please don't come back with
an argument such as the following is legal:

#define void int
#define main core
#define start {
#define end }

void core()
start
return 0;
end
Why not? It's a perfectly valid argument, and it's very similar to
what you're doing.

For that matter, the standard doesn't require any particular code
layout. There are a number of different conventions for indentation
and brace placement, but something like this is perfectly legal:

#include <stdio.h>
int main
( void
) {
printf("Hello, world\n"
);}

Maybe you need to get used to variety. Or maybe it's just horribly
bad style.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Aug 8 '06 #118
Keith Thompson said:
Frederick Gotham <fg*******@SPAM .comwrites:
>>
I like my style though.

Ok. What about anyone else who reads your code?
If you don't like it, don't read it.

I don't like it, so I won't read it.

But how he writes his code is up to him. If he doesn't need other people to
read it (e.g. to help him out), then as long as he can read it, that's all
that matters.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Aug 8 '06 #119
Al Balmer posted:
>>Perhaps you'd like to post some of your own code, and I'll point out the
flaws?

I wouldn't bother, since you and I obviously have very different ideas
as to what constitutes good code.

I'll just say that if you presented the examples you've shown in a
code review here, you'd be told to fix them.

Who said anything about a code review? My programming doesn't undergo a
"code review", and so I don't have to dumb it down and suck the efficiency
out of it to satisfy the politics of whomever I work for.

If the second review wasn't drastically improved, there wouldn't be a
third.

If my second try was 40% less efficient the second time around, would it
make the cut?

So, do your own thing, but I hope no one else ever has to deal with
it.

God forbid they might actually adopt my style.

--

Frederick Gotham
Aug 8 '06 #120

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

Similar topics

1
1848
by: Lefevre | last post by:
Hello. I recently discovered that this kind of code : | struct Object | { | string f() { return string("Toto"); } | } | | int main( ... )
0
9901
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
11031
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...
0
10685
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10763
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
9518
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
7918
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
7082
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
5750
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5942
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.