Thread: What is "far"??

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    88

    What is "far"??

    THX~

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    34
    far is a area of memory that is outside of the usual 16-bit (64k) of program memory.

    DOS programs run in 16-bit, hence 64k of program memory (known as 'near' memory),If you declare an array of 68k in a 16-bit program, you will get a compiler error.

    FAR is used to tell the compiler that the data is to be placed outside of this program memory limitation, and in the system memory.

    This can also be expanded, and can be used to declare a FAR pointer to an address outside on the 64k (e.g. a LPT port)

    Code:
    // near and far arrays:
    char Buffer[68000]; // compiler error in win16
    char _far Buffer[68000]; // compiler ok.


    NOTE! in win32 programs, we use 32-bit pointers, and therefore ALL pointers are FAR pointers by default, we are not limited to 64k.

    joe
    #

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    34
    Originally posted by Salem
    A redundant keyword for a forgotten compiler, running on a fossil operating system
    Actually its used all the time for embedded systems that rely on the old 16-bit dos platform.

    But for all those that dont program dos, then i guess the last time you typed FAR was when you emailed the boss with your program progression report... "not FAR to go now..."

    joe
    #

  4. #4
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    my only current work with far involves taking it OUT of code. It's defined as nothing now. There are a ton of things in Win32 that are defined as nothing and are just used to annoy me. IN and OUT for instance are supposed to be helpful in making a parameter list descriptive. I hate them. for instance:

    void FuncName(int IN a, int IN b, int OUT *c);

    it can be seen as helpful in readability but it means nothing.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  5. #5
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380
    lol, my only encounter with NEAR and FAR pointers is as FillYourBrain said, is with removing it

    I've never in my time of programming used NEAR and FAR pointers.

  6. #6
    Registered User
    Join Date
    Jul 2002
    Posts
    34
    well, some of us still have to use them for DOS programming


    joe
    #

  7. #7
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Originally posted by kybert
    well, some of us still have to use them for DOS programming


    joe
    #
    use djgpp
    hello, internet!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. "far"?
    By SgtMuffles in forum C Programming
    Replies: 7
    Last Post: 04-05-2005, 07:08 AM