Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Writing "absolutely" portable code

Reply
Thread Tools

Writing "absolutely" portable code

 
 
Seebs
Guest
Posts: n/a
 
      01-21-2012
On 2012-01-18, Joachim Schmitz <> wrote:
> io_x wrote:
>> afther say that, i kill file you and Ian Collins


> They will be deeply impressed.


Man. Now I want to know what I have to say to get io_x to kill file me.

-s
--
Copyright 2011, all wrongs reversed. Peter Seebach / usenet-
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
 
Reply With Quote
 
 
 
 
Seebs
Guest
Posts: n/a
 
      01-21-2012
On 2012-01-18, Kaz Kylheku <> wrote:
> On 2012-01-18, Seebs <usenet-> wrote:
>> It's more subtle than that, apparently, and was most recently fixed in January
>> of 2007. Looking at it, it appears that all the standard stuff in bash's
>> configure uses a value bash_cv_job_control_missing, which would normally be
>> set to either "present" or "missing". We had a build file which was setting it
>> to "no", but was not setting it in the right way; it looks to me as though
>> the intent had been the logical equivalent of:
>> bash_cv_job_control_missing=no configure <args>
>> but it ended up working as though it were:
>> bash_cv_job_control_missing=no
>> configure <args>


> Ah, let me guess, missing backslash?


Nothing so obvious! In the original it was Makefile variables, then we moved
to an SRPM package, and the SRPM package had
bash_cv_job_control_missing=no \
%configure [...]

and apparently this doesn't work, but changing it to "export" does. I don't
know the definition of %configure, but I'm guessing it was the underlying
mechanic.

.... I know none of this is really relevant to C, but it *is* somewhat relevant
to the question of why cross-compilation can be hard, and why I hate autoconf.
Stuff like this requires you to ensure that certain values are stashed in
environment variables or cache files, and that can be a nightmare to maintain.

I think experience with portability stuff like this is a great thing for any C
programmer. People who haven't had to deal with this are often quite quick to
carefully write multiple versions of something that each make unportable
assumptions; experience with this teaches the value of figuring out how to write
something that is portable in that it works everywhere, rather than in that it
works in three specific places.

I occasionally see people making things "portable" by doing things like:

#ifdef BIG_ENDIAN
#ifdef INT_32_BITS
if (((char *) x)[3] == 23) {
/* ... */
}
#else
if (((char *) x)[7] == 23) {
/* ... */
}
#endif
#else
if (((char *) x)[0] == 23) {
/* ... */
}
#endif

I would rather see:
if ((x & 0xff) == 23) {
/* ... */
}

-s
--
Copyright 2011, all wrongs reversed. Peter Seebach / usenet-
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      01-21-2012
On 01/22/12 10:32 AM, Seebs wrote:
> On 2012-01-18, Joachim Schmitz<> wrote:
>> io_x wrote:
>>> afther say that, i kill file you and Ian Collins

>
>> They will be deeply impressed.

>
> Man. Now I want to know what I have to say to get io_x to kill file me.


The truth!

--
Ian Collins
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing portable code... jacob navia C Programming 7 09-03-2007 10:29 PM
Portable Python - free portable development environment ! perica.zivkovic@gmail.com Python 7 01-13-2007 11:19 AM
Writing portable code in Visual Studio C++ Richard Giuly C++ 5 07-31-2006 03:49 PM
portable (VHDL) vs. non-portable (altera LPM) approaches to signed computations Eli Bendersky VHDL 1 03-01-2006 02:43 PM
Writing portable software Jason Curl C Programming 10 03-15-2005 10:29 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57