473,854 Members | 1,836 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 10370
"Frederick Gotham" <fg*******@SPAM .comwrote in message
news:19******** ***********@new s.indigo.ie...
Keith Thompson posted:
What I don't understand is how this quest leads you to declare things
backwards, using "int unsigned" rather than the far more common
"unsigned int". (Note that even in English grammar, "unsigned int"
makes more sense; "unsigned" is an adjective, and "int" is a noun --
not that that's a decisive argument.)

English is quite strange in that regard. I think most languages put their
words in order of descending importance. Irish for example:

window = fuinneog

small = beag

small window = fuinneog bheag

I think it makes sense to receive information in order of descending
importance. I like to know the type first and foremost, which is why I
prefer:

int const i = 5;

over:

const int i = 5;

It doesn't make much of a difference with small, simple, definitions, but
it certainly does work nice with long unwiedly ones.
And who defines importance? You, as a C++ programmer, should know that
sometimes type doesn't even matter. (That's why templates were created.)
Sometimes I'm much more interested in the fact that a variable is const than
the fact that it is an int. *Every* piece of information in the declaration
becomes important at some point.

Sticking to a common coding style between multiple programmers on the same
project makes looking for the piece of information you want *right now* much
easier. It's far more important to stick to a common coding style than to
invent a new one which you think is better but which nobody else is used to.

Since you are a lone programmer, agreement on your common coding style
becomes much easier and you can use whatever coding style you like. :)
You've invented a set of rules for how you order keywords, taking
advantage of the fact that the compiler doesn't care. The result is
difficult to read for 99% of C programmers. It's not impossible to
read, just annoyingly difficult, and for no benefit that I can see.

I wouldn't have thought people would be so puzzled by the simple ordering
of words.
I can see exactly why you and Keith keep disagreeing in this respect. You
are saying that the code has exactly the same information as before, so any
programmer worth his salt would be able to work out what the declaration
meant, whatever the word order. And you're right. It certainly is still just
as possible to get the same information.

However, the same programmer, when presented with a word order he is not
familiar with, will take longer to read it, and will have to think more, and
(quite possibly) will be frustrated by this fact. The code is not
unreadable; but it *is* less readable.

--

Philip Potter
Aug 9 '06 #161
Richard posted:
> for(size_t i = len - 1; i != -1; --i)
Its not cryptic : it just plain sucks and may well be inefficient too.

Care to express why you think it "plain sucks", and why it may be well be
inefficient too?

--

Frederick Gotham
Aug 9 '06 #162
Philip Potter posted:
>I wouldn't have thought people would be so puzzled by the simple
ordering of words.

I can see exactly why you and Keith keep disagreeing in this respect.
You are saying that the code has exactly the same information as before,
so any programmer worth his salt would be able to work out what the
declaration meant, whatever the word order.

Precisely.

Consider an internal linkage, inline function which returns a const pointer
to a const int. Each of the following are easily readable to me:

inline static const int * const Func1(void) {}

static inline int const* const Func2() {}

const static int inline *const Func3(void) {}

int const inline static* const Func4() {}

And you're right. It certainly is still just as possible to get the same
information.

However, the same programmer, when presented with a word order he is not
familiar with, will take longer to read it, and will have to think more,
and (quite possibly) will be frustrated by this fact. The code is not
unreadable; but it *is* less readable.

I don't quite agree. The only time I need to pay attention to word order in a
C definition is whether a "const" is placed before or after an asterisk:

int const *p;
int *const p;

Other than that, I just scan the words and take meaning from them.

--

Frederick Gotham
Aug 9 '06 #163
Philip Potter posted:
>It doesn't make much of a difference with small, simple, definitions,
but it certainly does work nice with long unwiedly ones.

And who defines importance? You, as a C++ programmer, should know that
sometimes type doesn't even matter. (That's why templates were created.)

Not quite, I still want to see the types:

template<class RetType, class ArgType>
RetType const inline *Func(ArgType arg)
{

}

--

Frederick Gotham
Aug 9 '06 #164
Keith Thompson <ks***@mib.orgw rote:
Frederick Gotham <fg*******@SPAM .comwrites:
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?
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.

Richard
Aug 9 '06 #165
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.

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.

Richard
Aug 9 '06 #166
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.

--

Frederick Gotham
Aug 9 '06 #167
Frederick Gotham <fg*******@SPAM .comwrites:
Richard posted:
>> for(size_t i = len - 1; i != -1; --i)
>Its not cryptic : it just plain sucks and may well be inefficient too.


Care to express why you think it "plain sucks", and why it may be well be
inefficient too?
Sure : I'm just expressing my individuality and unsupported opinion as
you like to do :-; And it was explained to you on c++ forum.

It is much more common, and often faster, to a zero check as the
limiting condition. Maybe the compiler will do it for you. I dont know.

while(count--)
arr[count]=val;

But this is religious stuff.
Aug 9 '06 #168
Frederick Gotham <fg*******@SPAM .comwrites:
Philip Potter posted:
>>I wouldn't have thought people would be so puzzled by the simple
ordering of words.

I can see exactly why you and Keith keep disagreeing in this respect.
You are saying that the code has exactly the same information as before,
so any programmer worth his salt would be able to work out what the
declaration meant, whatever the word order.


Precisely.

Consider an internal linkage, inline function which returns a const pointer
to a const int. Each of the following are easily readable to me:

inline static const int * const Func1(void) {}

static inline int const* const Func2() {}

const static int inline *const Func3(void) {}

int const inline static* const Func4() {}

>And you're right. It certainly is still just as possible to get the same
information.

However, the same programmer, when presented with a word order he is not
familiar with, will take longer to read it, and will have to think more,
and (quite possibly) will be frustrated by this fact. The code is not
unreadable; but it *is* less readable.


I don't quite agree. The only time I need to pay attention to word order in a
C definition is whether a "const" is placed before or after an asterisk:

int const *p;
int *const p;

Other than that, I just scan the words and take meaning from them.
Would you be able to read the code as well if someone stripped out all
the whitespace?
Aug 9 '06 #169
Richard Heathfield wrote:
Phlip in c.p has made himself a right PITN by going on and on and on about
TDD. Please don't make the same mistake. The clc group is about the C
language, not about development strategies.
This is a new low for you, Richard - invoking my name to flame someone else.

Maybe TDD is spreading, if anyone besides me deigns to bring it up...

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Aug 9 '06 #170

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
10684
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
10371
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
9517
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
5744
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?
1
4563
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
4159
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3188
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.