473,839 Members | 1,471 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
Frederick Gotham <fg*******@SPAM .comwrites:
I wouldn't have thought people would be so puzzled by the simple ordering
of words.
I be by have ordering people puzzled simple so the thought would
wouldn't of words.

--
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 9 '06 #191
Frederick Gotham wrote:
Richard Bos posted:
>>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?
Don't you think that you're being just a _little_ extreme? At the very
least you have to admit that Frederick's order is legal, correct,
logical, internally consistent (which cannot be said of most code out
there, which throws consts around /ad libitum/), and if applied
throughout his code base, pretty clearly intentional. It might not be
your preferred order of specifiers, but for heavens' sake, if you're
going to spend a whole our getting used to it, you're dyslexic.

If the word order in definitions/declarations was purely at the programmer's
discretion, then perhaps it would be beneficial to view them as if you're
dyslexic! I only pay attention to whether a const is placed before or after
an asterisk... it's a free-for-all after that.
I know for a fact there is at least one dyslexic programmer on this
group, and the person I am thinking of finds is easier if a consistent
style is used, and easiest if the consistent style is the one he deals
with most of the time.
--
Flash Gordon
Dyslexic Programmer with a certificate to prove it.
At least the compiler ensures I spell variable names consistently wrong.
Aug 9 '06 #192
Frederick Gotham wrote:
Flash Gordon posted:
>The reality is that when more than one person works on a project it is
far easier to read if everyone uses the same coding style and in the
real world the majority of complex pieces of software are worked on by
multiple people.


I think this argument is exagerated. I can read any style, so long as it's
valid C. I'll admit, that at first, there were some things which puzzled
me, things like:

sizeof obj

instead of:

sizeof(obj)
Never gave me a problem.
Or:

int const *p;

instead of:

const int *p;
Neither of these has puzzled me either. However, I have to slow down for
the one I'm not used to and if I'm scanning back up to check some aspect
of the type of p then instead of scanning and immediately picking out
the aspect I want to know I'll have to stop and read it.
But is that not part of learning C? Some people put their function blocks
like so:

int Func()
{

}

while others put them like so:

int Func() {

}

It might be a little puzzling the first time you encounter it, and you
might even find it disgusting, but if you look at it objectively, you can
still read the code.
Yes, but for the style you do not generally use it slows you down. If
you see
int Func() {
int i;

You may well have to pause a moment to confirm that there is nothing in
the parenthesis and so i is a local variable rather than a parameter.
If you were to supply me with a source file which contained several
different styles, I wouldn't have a problem reading it.
I would still be able to read it, I know because I have had to, but it
slows most people down. It especially slows people down when they are
scanning just to check something.

Some of us can be asked to review a few thousand lines of C code.
Anything that slows you down on this in a busy day is undesirable.

For your own code seen by no one else do whatever you please. I'm just
explaining why when more than one person is involved it is advisable to
stick to a consistent style, and where there is a commonly accepted
style it is generally easiest to stick to it.

I'm not going to continue responding to this since it is a style issue
and you never get everyone agreeing (I've accepted Pascal coding styles
I did not like because it was the standard for the project). Although
the fact that most people posting an opinion seem to think your coding
style is less readable might give you a hint.
--
Flash Gordon
Still sigless on this computer
Aug 9 '06 #193
mw*****@newsguy .com (Michael Wojcik) writes:
In article <87************ @mail.com>, Richard <rg****@gmail.c omwrites:
>"Philip Potter" <ph***********@ xilinx.comwrite s:
<we******@gmail .comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
*something in which the content was lost in a swathe of personal attacks*

Calm down. You do not make your points any clearer by insulting
others and ignoring their arguments. While I think that *what*
you were saying has some validity [1], the way you said it was
completely OTT.

He wasnt overly rude : just somewhat miffed, as a lot of posters get,
when dealing with the typically overtly imperious tone taken by a
certain poster.

You think *Keith* was "imperious" , compared to Paul? You may have the
oddest sense of prose style I have ever encountered, and I used to
teach literature at university.
It's not quite clear to me who Richard was saying wasn't "overly
rude", and who he was saying takes a "typically overtly imperious
tone". Richard, would you care to clarify?

--
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 9 '06 #194
Richard Bos wrote:
Ian Collins <ia******@hotma il.comwrote:

>>Frederick Gotham wrote:
>>>I am predominantly a C++ programmer, however I can program in C.

My own code does not suffer from any restrictions which a company may
impose, and so I strive to write quality, fully-portable, Standard-
compliant, efficient code.

Commendable objectives.

It may not be popular in these parts, but I'd recommend you become
familiar with Test Driven Development as a way of enhancing the quality
of your code, both in design and implementation.


Dunno about you, but if we're bandying manglement terms about, I prefer
to employificate Programmer Driven Development.
I'm not.
Last year it was Pattern Driven Development. The year before that Rapid
Development. Now Test Driven Development is apparently the buzzword of
the day. Bah. My tests test my program development; they do not drive
it. _I_ do that.
So someone else drives you tests?

--
Ian Collins.
Aug 9 '06 #195
Frederick Gotham wrote:
Flash Gordon posted:

>>The reality is that when more than one person works on a project it is
far easier to read if everyone uses the same coding style and in the
real world the majority of complex pieces of software are worked on by
multiple people.

I think this argument is exagerated.
No it isn't. You say that you don't work in a team, so you don't have
any basis for that statement.

Look at any large opensource project and you will find a coding
standard, with will be enforced with the same rigour as topicality on
this group!

The same applies for each of the many commercial applications I have
worked on.

--
Ian Collins.
Aug 9 '06 #196
Keith Thompson posted:
Frederick Gotham <fg*******@SPAM .comwrites:
>I wouldn't have thought people would be so puzzled by the simple ordering
of words.

I be by have ordering people puzzled simple so the thought would
wouldn't of words.

No, I'd consider it more akin to:

a big, yellow, smooth, painted wall

instead of:

a smooth, yellow, painted, big wall

There are times when the order doesn't change the meaning.

--

Frederick Gotham
Aug 9 '06 #197
Phlip wrote:
Ian Collins wrote:

>>ena8t8si wrote:

>>>Having said that, the reigning culture in comp.lang.c
is to remind contributors about what's considered
topical, and especially what isn't.

I don't see you jumping on anyone who advocates the development strategy
of using a debugger to work out why something doesn't work. If I were
to dare to suggest they write some tests, I'm sure you'd pile in and
accuse me of proselytising.

Topicality is in the eye of the beholder.


Enforcing topicality helps a newsgroup grow a crew of regulars, without
boring them with endless questions like, "How do I click on the VC++ Class
Wizard?"
I don't dispute that, what I do object to is some one using topicality
as a cover for a personal agenda.

This year I have mentioned TDD in two threads here, both times he or she
has piled in with a personal attack. The first time on a thread that
was weeks old, no way that could be considered topicality guidance.

--
Ian Collins.
Aug 9 '06 #198
Frederick Gotham <fg*******@SPAM .comwrites:
Keith Thompson posted:
>Frederick Gotham <fg*******@SPAM .comwrites:
>>I wouldn't have thought people would be so puzzled by the simple ordering
of words.

I be by have ordering people puzzled simple so the thought would
wouldn't of words.

No, I'd consider it more akin to:

a big, yellow, smooth, painted wall

instead of:

a smooth, yellow, painted, big wall

There are times when the order doesn't change the meaning.
No, it doesn't change the meaning -- and in this case, it doesn't
matter because there's no conventional ordering for those words.

In C, there is a conventional ordering, though it's not imposed by the
rules of the language.

I have tried several times to explain why your chosen style merely
makes your code more difficult for others to understand.

I posted a C example where I sorted the keywords alphabetically. That
example is, for most of us, no more or less difficult to read than
your style with the "most important" keywords first. Anything other
than the conventional ordering used in most actual C code, and in the
examples in the standard, is more difficult to read, and with no
benefit for anyone other than you.

If you promise not to post any such code here, I won't complain about
it again. If you do post such code, don't expect anyone to spend the
extra time required to figure it out.

--
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 9 '06 #199
Keith Thompson posted:
>No, I'd consider it more akin to:

a big, yellow, smooth, painted wall

instead of:

a smooth, yellow, painted, big wall

There are times when the order doesn't change the meaning.

No, it doesn't change the meaning -- and in this case, it doesn't
matter because there's no conventional ordering for those words.

In C, there is a conventional ordering, though it's not imposed by the
rules of the language.

This newsgroup is for the discussion of the C language as described by the
Standard(s).

I don't think either of the Standards indicate that one should write:

int const *p;

rather than:

const int *p;

If it wanted to impose such a restriction, it would.

If you promise not to post any such code here, I won't complain about
it again. If you do post such code, don't expect anyone to spend the
extra time required to figure it out.

If they need the extra time to figure it out, then they probably can't help
me anyway. If you're expecting someone to say:

a big, yellow, smooth, painted wall

and instead, they say:

a smooth, yellow, painted, big wall

, then will you be confused, and will it take you longer to decipher the
sentence?

What puzzles me more than anything is that you even pay attention to the
ordering of the words. The only time it comes into play is whether "const"
and "volatile" and "restrict" appear before or after an asterisk. The rest
of the time, it's irrelevant.

--

Frederick Gotham
Aug 9 '06 #200

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
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
10584
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
10645
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
10290
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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
5865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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
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.