Tom Collins

CW10: __near doesn't force function to non-banked address

Discussion created by Tom Collins on Jun 8, 2011
Latest reply on Jun 9, 2011 by Tom Collins

I'm trying to force a function to be non-banked so I can store its address in a (void *).  I thought that this syntax:

 

int __near foo1( void){    return 42;}

would be sufficient, and it was enough to quiet the compiler warnings when trying to assign the address of foo to a void pointer.  But when I checked the MAP file, it had been compiled to banked memory.

 

I ended up using this syntax:

#pragma CODE_SEG __NEAR_SEG NON_BANKEDint foo2( void){    return 42;}#pragma CODE_SEG DEFAULT

Why doesn't the first version work?  In my test, foo1 was banked and foo2 was not.  The __near keyword is certainly cleaner, especially for multi-platform code (we can define a macro NEAR to be __near when necessary, or a null macro otherwise).

 

-Tom

Outcomes