Saturday, October 16, 2021

FAR type in old C/C++ language

FAR type in old C/C++ language

  1. What are near, far and huge pointers?
  2. These are some old concepts used in 16 bit intel architectures in the days of MS DOS, not much useful anymore. Near pointer is used to store 16 bit addresses means within current segment on a 16 bit machine. The limitation is that we can only access 64kb of data at a time..

    A far pointer is typically 32 bit that can access memory outside current segment. To use this, compiler allocates a segment register to store segment address, then another register to store offset within current segment.

    Like far pointer, huge pointer is also typically 32 bit and can access outside segment. In case of far pointers, a segment is fixed. In far pointer, the segment part cannot be modified, but in Huge it can be

  3. What is the difference between far pointers and near pointers?
  4. Can anybody tell me the difference between far pointers and near pointers in C?.

  5. far pointer declaration in Visual Studio
  6. I have a far pointer declaration in this way:

    char far *p;

    But visual studio 2008 give me

    error C2146: missing ';' before identifier 'p'

    Any help is appreciated.

  7. far pointer declaration in Visual Studio
  8. I have a far pointer declaration in this way:

    char far *p;

    But visual studio 2008 give me

    error C2146: missing ';' before identifier 'p'

    Any help is appreciated.

    The answer to your question is also in the blog that you linked to, but it's mentined in a kind of round about way:

    If you open up the Property Manager view to see the property sheets associated with your project, you’ll see that one of the property sheets is named Microsoft.Cpp.Win32.User. This property sheet is actually stored in LocalAppData, just as VCComponents.dat file was, in the directory %LocalAppData%MicrosoftVisualStudio10.0. Using the property editor on the property sheet (just right-click on this property sheet node and select Properties…), you can see that you are able to make edits directly to this file. Since all projects, by default, import this property sheet, you are effectively editing the VC++ directories in the same way you were able to do before.

    The key is that you get to the VC++ Directories property through the "Property Manager" windows (open it via the View/"Property Manager" menu selection). The VC++ Directories setting is in the "Microsoft.Cpp.Win32.user" property sheet - that edits the global setting, so you should only have to do it once.

    There seem to be quite a few people who dislike this change; I think that's because it's less discoverable and obvious than how the setting was managed before. The trade-off is that it's more flexible and integrates into the MSBuild architecture better, and once you do know about it it's just as easy to change as before (it's just harder to find, particularly if you're used to the old place).

No comments:

Post a Comment