Thread: where from extern int errno came ?

  1. #1
    Registered User
    Join Date
    Apr 2007

    where from extern int errno came ?


    few minutes ago i was noted that using extern int errno is actually a mistake but the problem is that as far as i remember coding in C (the last year) i used that form.

    where from this behavior came from in the beginning ?
    what i mean is why do people use extern int errno (i know that i saw it somewhere )
    why Gaos didn't had a wife ?

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    No idea what you're really talking about, but I think the proper way to use errno is to include errno.h.... Trying to manually include functions or variables is probably not a good idea since each compiler handles these things in their own way.

    Edit: OK, after reading this other topic, I think my answer is in line with what are asking, but your question has already been answered there.
    Last edited by MacGyver; 10-14-2007 at 04:53 PM.

  3. #3
    Registered Abuser
    Join Date
    Jun 2006
    All you need is in the man page:
    It is unspecified whether errno is a macro or an identifier declared with external linkage. If a macro definition is suppressed in order to access an actual object, or a program defines an identifier with the name errno, the behavior is undefined.
    Which means if you declare it as extern int as you say above, you're playing with fire. You may get lucky if your implementation defines errno as an int, but if it defines it as a macro, you're screwed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 10-29-2006, 05:04 AM
  2. Working with random like dice
    By SebastionV3 in forum C++ Programming
    Replies: 10
    Last Post: 05-26-2006, 09:16 PM
  3. Game Won't Compile
    By jothesmo in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2006, 04:24 PM
  4. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM