473,839 Members | 1,464 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 10352
Ian Collins posted:
I pity anyone who has to maintain your code.

Me too if they can't get their head around word order.

--

Frederick Gotham
Aug 8 '06 #101
Frederick Gotham said:
Ian Collins posted:
>I pity anyone who has to maintain your code.

Me too if they can't get their head around word order.
If Yoda great Jedi Master is, why English sentences he cannot in the right
order speak?

--
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 #102
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.

> 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;

--

Frederick Gotham
Aug 8 '06 #103
Frederick Gotham wrote:
Ian Collins posted:

>>I pity anyone who has to maintain your code.

Me too if they can't get their head around word order.
They shouldn't have to. The excellent quote at the end of Keith's
comment is very pertinent to your style.

--
Ian Collins.
Aug 8 '06 #104
Keith Thompson <ks***@mib.orgw rites:
Frederick Gotham <fg*******@SPAM .comwrites:
>Keith Thompson posted:
>>Yes, it is. And how exactly is that useful? "int unsigned" is legal,
but all it's going to do is confuse the reader.

People have different coding styles.

Yes. That doesn't mean all styles are equally good.
>>"unsigned int" or just "unsigned" is far more common, and won't confuse
the reader.

Is there some reason you want to confuse your readers?


When I have a definition (or a declaration), I put things in order of
descending importance. The most important thing comes first.

First and foremost, I specify the type.

Next, I specify things such as "long", "short".

Next, I specify signedness, e.g. "signed", "unsigned".
[..]

Ok, so your style is internally consistent, but it's inconsistent with
perhaps 99.73% of other C programmers (I made up that number).
> 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.
And aint that the truth. I have a feeling that Fred has recently
mastered a few keywords and is bursting to use them.
>
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.
Very good. But there is something more important : concistency across
code base and anyone (I often suspect that not many here do) who works
on large, legacy systems knows the importance of good clear basic coding
styles which can be relatively easily understood by anyone with a
reasonable knowledge of the programming language in question.

I remember having one guy express his displeasure at the new edicts
which pretty much banned him from using his programming creativity on a
company code base. He was informed that at home he could program as he
saw fit : but on the huge, maintained system it was the documented way
or the highway.
Aug 8 '06 #105
Frederick Gotham wrote:
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.
You're probably mistaken there, but this is a C group.

--
Ian Collins.
Aug 8 '06 #106
"Frederick Gotham" <fg*******@SPAM .comwrote in message
news:Pt******** ***********@new s.indigo.ie...
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.
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. People get bogged down reading syntax and will spend less time
worrying about what the code actually *does*.
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
Do people brain-freeze when they see a Dvorak keyboard? No. It's still got
the same number of letters as a QWERTY keyboard, just in a different order.
They haven't forgotten English, so they can clearly still use it for typing.

The problem is familiarity. If things are not familiar, then no matter how
"obvious" or "simple to work out" they are, they will take more time to
understand.

(Of course, if your local coding environment uses "int const *p" instead of
"const int *p" then you should stick with it.)
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;
That's perfectly fine for a solitary developer. When more than one person
works on a piece of code, arbitrary clashing code styles will generally
cause more harm than good.

--
Philip Potter

Aug 8 '06 #107
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 ?
(thanks & sorry, just curious)

Aug 8 '06 #108
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:

int const *p;

const int *p;

static inline int Func(...

int inline static Func(...

inline static int Func(...

static int inline Func(...

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?

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

--

Frederick Gotham
Aug 8 '06 #109
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:
You have clearly never had to do so.

In large code bases "other peoples codings" might just be 3 lines in a
200 line module : its called maintenance.

I've managed teams of up to 35 programmers and people who refuse to
conform to a (relatively liberal) coding standard soon become very, very
unpopular. There is really no excuse for "going it alone" in code bases
which are maintained globally by possibly hundreds of programmers and
which, invariably, end up in the customers hands for "on site"
tweaking. It is unprofessional and hard to keep up with.

Not only that, but when certain "initiative s" like the latest "must
have" ISO blah blah are ordered in by higher management, then non
conforming code can be very hard to recognise standard typings etc for
isolating the change areas.

Aug 8 '06 #110

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
9854
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
9696
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
10903
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
9425
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...
0
7015
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
5681
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...
1
4482
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 we have to send another system
2
4063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3131
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.