how to tell near from far pointers

"[email protected] [rabbit-semi]" <[email protected]> 06 Oct 2016 03:57:22 -0700
Newsgroups gmane.comp.hardware.rabbit-semiconductor
Message-ID <[email protected]>
Does anybody know what is the standard way to tell if a pointer can be safely casted to near?

Here is a sample program:
 

 #include "xbee/platform.h"
  
 void my_dump(void far *address)
 {
   const char far *data = address;
  
   printf("Address %" PRIpFAR, data);
   printf(" contains: 0x%02" PRIX8 ".\n", data[0]);
 }
  
 char far f[64];
 char n[64];
  
 void main ()
 {
   f[0] = 0x00;
   n[0] = 0x01;
   my_dump(f);
   my_dump(n);
 }

The output looks like this:

 Address 107FC0 contains: 0x00.                                                  
 Address FFFFB372 contains: 0x01. 

The "my_dump" function should be able to recognize a near pointer for proper formatting.

By the way ( address == (void far *)(void *)address ) is true when address is near, but it also throws a warning ("Explicit cast from pointer-to-far to pointer-to-near.")

Thank you.