Talk:Error code

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Historical context[edit]

Nice to add some historical context. When was the first use of Error codes? When did they become popular? When were they the standard? (80s I think) When did exceptions start replacing them? (90s?) Aharel (talk) 11:20, 19 March 2013 (UTC)[reply]

untitled[edit]

I'm yanking the "expansion" tag, since the article has grown quite significantly since it was added. scot 18:38, 1 December 2005 (UTC)[reply]

This sentence needs to be translated into English "Error codes are often process global variables, such as errno in C. " It's a wee bit cryptic for the average reader. --Lee Hunter 14:54, 11 Feb 2005 (UTC)

I've been a geek too long (started programming in 1980, at age 9) so it really makes my brain hurt to try to think like "the average reader". That phrase "process global variable" is probably worthy of several paragraphs. It also begs the question of just how global errno is on, say, bastardized "cooperatively mulitprocessing" machines like 16 bit Windows, which ran all processes in essentially the same address space. I've tried very hard to repress all memories of working under 16 bit Windows... I'll do some thinking on it and see if I can come up with a lower level explanation. scot 16:21, 11 Feb 2005 (UTC)

The example with "fopen" uses errno, but the page Fopen does not mention errno as part of the interface. As I understand whether fopen sets errno (even on failure) is implementation dependent (or an extension to the standard)?

 http://www.opengroup.org/onlinepubs/009695399/functions/fopen.html
 http://www.opengroup.org/onlinepubs/007908799/xsh/fopen.html

-- File Not Found 18:21, 2 September 2006 (UTC)[reply]

Some discussion may be added about the correct way to handle errno in C, because it is confusing and partially implementation dependent. I believe this is the most portable way to use errno in C.

 // example taken from http://www.brainbell.com/tutors/c/Advice_and_Warnings_for_C/Macros_and_Miscellaneous_Pitfalls.html
 // in section "Gently Down the Stream"
errno = 0;
fileptr = fopen( ... );
if ( fileptr == NULL )  {
  /* An error occurred in fopen()
  | Now it's valid to examine errno
  */
  if ( errno != 0 ) {
  /* handle error */
  }
}
-- File Not Found 18:47, 2 September 2006 (UTC)[reply]