473,841 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing portable code...

There are some people here (let's call them "regulars" for short)
that are always giving lessons to people about how easy is to
write portable code, etc. They always point fingers at you telling you
how bad you write code.

One of them (I would say the prototype of them) is Heathfield.

Here is an exchange that happened just a few hours ago, that
demonstrates my point:

WRITING CODE IS HARD. And regulars aren't better at it than everybody
else...

Ed Jensen wrote
There are very few regulars here in comp.lang.c that'll admit that
writing 100% portable C code is non-trivial.
Then, Heathfield answered:
I'm one of them, however.
I think it's easy to write *very* portable code, but difficult to write
100% portable code. Consider, for example, this simple program:
[code snipped]

Harald van Dijk answered:
>I can see one very obvious bug: you're using a file after closing it.
That's not the way you should be writing code even if it's not meant
to be portable.
And Heathfield had to acknowledge...
Oh, stupid stupid stupid (me, not you). You're right, of course. That
was unintentional, by the way!
>
Sep 2 '07 #1
7 1882
On Sun, 02 Sep 2007 10:52:51 +0200, jacob navia wrote:
There are some people here (let's call them "regulars" for short)
that are always giving lessons to people about how easy is to
write portable code, etc. They always point fingers at you telling you
how bad you write code.

One of them (I would say the prototype of them) is Heathfield.

Here is an exchange that happened just a few hours ago, that
demonstrates my point:

WRITING CODE IS HARD. And regulars aren't better at it than everybody
else...
If you mean that regulars are human, they are, but your statement
with its verbatim meaning is only true for sufficiently small
values of "everybody else" <flame>(e.g. you shouldn't be included
in it)</flame>.
Ed Jensen wrote
There are very few regulars here in comp.lang.c that'll admit that
writing 100% portable C code is non-trivial.

Then, Heathfield answered:
I'm one of them, however.
I think it's easy to write *very* portable code, but difficult to write
100% portable code. Consider, for example, this simple program:

[code snipped]

Harald van Dijk answered:
>I can see one very obvious bug: you're using a file after closing it.
>That's not the way you should be writing code even if it's not meant
>to be portable.
>

And Heathfield had to acknowledge...
Oh, stupid stupid stupid (me, not you). You're right, of course. That
was unintentional, by the way!
>
If someone has anything to say about that, they'll answer on that
thread. And your question about C was?
--
Army1987 (Replace "NOSPAM" with "email")
No-one ever won a game by resigning. -- S. Tartakower

Sep 2 '07 #2

"Army1987" <ar******@NOSPA M.itwrote in message
news:pa******** *************** *****@NOSPAM.it ...
On Sun, 02 Sep 2007 10:52:51 +0200, jacob navia wrote:
>WRITING CODE IS HARD. And regulars aren't better at it than
everybody else...

If you mean that regulars are human, they are, but your statement
with its verbatim meaning is only true for sufficiently small
values of "everybody else" <flame>(e.g. you shouldn't be included
in it)</flame>.
A C compiler is quite a difficult piece of software to write. I planned to
write one as a followup to MiniBasic, but shrank from the challenge.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Sep 2 '07 #3
jacob navia <ja***@jacob.re mcomp.frwrites:
There are some people here (let's call them "regulars" for short)
that are always giving lessons to people about how easy is to
write portable code, etc. They always point fingers at you telling you
how bad you write code.

One of them (I would say the prototype of them) is Heathfield.

Here is an exchange that happened just a few hours ago, that
demonstrates my point:

WRITING CODE IS HARD. And regulars aren't better at it than everybody
else...

Ed Jensen wrote
>There are very few regulars here in comp.lang.c that'll admit that
writing 100% portable C code is non-trivial.

Then, Heathfield answered:
>I'm one of them, however.
I think it's easy to write *very* portable code, but difficult to write
100% portable code. Consider, for example, this simple program:

[code snipped]

Harald van Dijk answered:
>>I can see one very obvious bug: you're using a file after closing it.
That's not the way you should be writing code even if it's not meant
to be portable.

And Heathfield had to acknowledge...
>Oh, stupid stupid stupid (me, not you). You're right, of
course. That
was unintentional, by the way!
>>
Was it? Wow. If all of us neglected to make the unintentional mistakes I
fee sure the standards of our code would greatly improve.....

Sep 2 '07 #4
Malcolm McLean wrote:
>
"Army1987" <ar******@NOSPA M.itwrote in message
news:pa******** *************** *****@NOSPAM.it ...
>On Sun, 02 Sep 2007 10:52:51 +0200, jacob navia wrote:
>>WRITING CODE IS HARD. And regulars aren't better at it than
everybody else...

If you mean that regulars are human, they are, but your statement
with its verbatim meaning is only true for sufficiently small
values of "everybody else" <flame>(e.g. you shouldn't be included
in it)</flame>.
A C compiler is quite a difficult piece of software to write. I planned to
write one as a followup to MiniBasic, but shrank from the challenge.
Indeed. However jacob has, to my knowledge, written only the machine code
generating and optimising portions of lcc-win32. The front-end is mostly
lcc. But I'm not deprecating his efforts.

Sep 2 '07 #5
jacob navia wrote:
There are some people here (let's call them "regulars" for short)
that are always giving lessons to people about how easy is to
write portable code, etc. They always point fingers at you telling you
how bad you write code.

One of them (I would say the prototype of them) is Heathfield.

If I post code, I like to get it corrected. Don't you?

Sometimes, the mistakes are rather uninteresting, typos that would be
detected by a compiler anyway, but in other cases the experts do teach
me something new.

Regulars that post solid code, are a great asset, "anybody" can post a
quote from the standard.
My PB for a clean compile in C, is ca a 1600 liner... that don't mean it
was bug-free.

--
Tor <torust [at] online [dot] no>
Sep 2 '07 #6
On Sep 2, 9:52 am, jacob navia <ja...@jacob.re mcomp.frwrote:
There are some people here (let's call them "regulars" for short)
that are always giving lessons to people about how easy is to
write portable code, etc. They always point fingers at you telling you
how bad you write code.

One of them (I would say the prototype of them) is Heathfield.
I wuda used a word something like apotheosis.

Here is an exchange that happened just a few hours ago, that
demonstrates my point:

WRITING CODE IS HARD. And regulars aren't better at it than everybody
else...

It's piss easy really.

Still preaching about your own incompetence.

Martin

Sep 3 '07 #7
On Sun, 02 Sep 2007 19:12:34 +0530, santosh wrote:
Malcolm McLean wrote:
>>
"Army1987" <ar******@NOSPA M.itwrote in message
news:pa******* *************** ******@NOSPAM.i t...
>>On Sun, 02 Sep 2007 10:52:51 +0200, jacob navia wrote:

WRITING CODE IS HARD. And regulars aren't better at it than
everybody else...

If you mean that regulars are human, they are, but your statement
with its verbatim meaning is only true for sufficiently small
values of "everybody else" <flame>(e.g. you shouldn't be included
in it)</flame>.
A C compiler is quite a difficult piece of software to write. I planned to
write one as a followup to MiniBasic, but shrank from the challenge.

Indeed. However jacob has, to my knowledge, written only the machine code
generating and optimising portions of lcc-win32. The front-end is mostly
lcc. But I'm not deprecating his efforts.
Frankly, if the generation and optimization portions are any good, that'd
be quite a feat in and of itself.
Sep 3 '07 #8

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

Similar topics

4
2478
by: aaronfude | last post by:
Hi, Perhaps this is slightly offtopic. Coming into the Windows world from Unix. Is there a reference on writing C++ libraries in a portable way. For example, right now I'm sticking "__declspec(dllexport)" in front of each of my classes. I guess I can still make it work on Unix bydefing
385
17387
by: Xah Lee | last post by:
Jargons of Info Tech industry (A Love of Jargons) Xah Lee, 2002 Feb People in the computing field like to spur the use of spurious jargons. The less educated they are, the more they like extraneous jargons, such as in the Unix & Perl community. Unlike mathematicians, where in mathematics there are no fewer jargons but each and every one are
10
2196
by: Jason Curl | last post by:
Dear C group, I'm very interested in writing portable C, but I only have GNU, Sparc and Cygwin to compile on. What I find is the biggest problem to writing portable C is what headers to include. What sites do people know about that are comprehensive in their differences? For example, MacOSX complained about <string.h>. With Solaris I needed
6
1386
by: Abubakar | last post by:
Hi, we are finding out ways in which we could develop libraries that could be written in c++ in a way that we can use them in windows, linux, and mac os. We want to write portable code, so that it could be build on mac os, linux, and windows. The code would involve lots of multi-threading and network/socket programming. Since I have read that vc++ 2k5 supports a lot of standard c++ stuff, can it help me to acheive what I want or I will...
3
5147
by: jitu.csewizard | last post by:
hi overview: function sprintf(<buffername>,<format string>, .....) in this function you need to allocate the size of buffername before hand. question: function ssprintf(<buffername>,<format string>, .....) i need to write a funtion in time and space optimized way so that i
5
7638
by: Richard Giuly | last post by:
Hello, I would like to write "portable" C++ code that could theoretically run on linux, windows, and other platforms, and I'd like to use VS as the editor/compiler/linker. The simplest thing that seems to complie in VS is this: //VS example #include "stdafx.h"
6
2597
by: shalakasan | last post by:
Hi, I want to open a binary file and write to a specific location in File. Here is how my code looks like: int main() { long lbuf = 0; int lreadBytes = 0;
30
2019
by: mellyshum123 | last post by:
I'm wanting to write an int to a file, and so far I have written: const char buff; int num = 256 //for the sake of the example sprintf(buff, "%d", num); Now my question is what to do next. I could use fwrite, but I don't understand how the size works, I'm not sure if it writes out the whole buffer or not, and I definetly only want to write out "256."
16
2529
by: rahul | last post by:
void foo(void) { /* blah blah */ } char buf = {....}; memcpy( (void *)&foo, buf, sizeof buf); This thing is giving segmentation fault on RHEL 5/gcc 4.1. Is the text segment protected? I am assuming foo has enough space for buf.
0
9865
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
9706
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
10609
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
7848
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
7025
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
5691
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
4498
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
4082
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3140
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.