× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Why? Because it is the generally accepted recommendation - as stated
by Jon Paris as follows in his "Who Knew You Could..." redbook:

Then I disagree with Jon.

I have the utmost respect for Jon Paris. He's a guru's guru. However, the idea that his statements are infallible is absurd.

There are errors in that redbook. A few months ago I was looking for an example of the Qp0lProcessSubtree() API, and found an example in that redbook. I thought my problems were solved until I looked at the code. There are several things being done in that code that make no sense, and accomplish nothing -- there were some points that the author clearly didn't understand.

But, the redbook has still been a tremendous, tremendous benefit to the RPG community on the whole. And that's my point, you can be valuable without being 100% right about every detail.

In this case, it's something of the matter of an opinion. C programmers expect errno to be unchanged unless an error occurs. That's gospel to them. When you change it, you break that rule. Some programs rely on that feature. (Although, you could certainly argue that they shouldn't -- the fact is, some do.)

Now you're reading this and probably saying to yourself "but, the C programs won't be affected, I'm changing it in my RPG code, not their programs!". Maybe. As long as you know for certain that your RPG programs will never be called by C programs. Or from other RPG programmers like me who expect errno to work the way it does from C.

Of course, you may think your programs aren't ever going to be called by another program, and that you're therefore safe -- but -- how do you know what'll happen to your code in the future? 5 years from now? 10 years from now?

And when it becomes a habit to clear errno, will you remember when you're writing your service programs or utility programs that you shouldn't clear it there?

Not clearing it, and not expecting it to be cleared, are good habits to get into. In my opiion, they're the right way to do things, and I hope I've made my case so that you understand why.

Unfortunately, there are a few oddball C routines that only use errno to report errors -- they're far and few between -- but if you run into one of them then you MUST clear errno, or you won't be able to determine if they failed. In that circumstance, you shoudl save the original value of errno before clearing it, and restore that value afterwards.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.