[futurebasic] Re: [FB] Variable address rounded up Warning?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2005 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Mon, 31 Oct 2005 22:48:12 +1300
kappalab wrote:

> I have a little program for testing a simple dialog, and when I run  
> this program, it looks like running fine; however, there is a  
> warning says,
>
> "Warning: Variable address rounded up to even address
> in file Temp Project at line 42 in FBKILLPREFS
> ・・dim BoxDPrefs as prefsRecord"
>
> Is there anyone know what exactly this warning means? I would like  
> to eliminate it but cannot figure out how.
>

The 68000 processor used in the first Macs stopped with a bus error  
if you attempted to read or write a 2-byte variable at an odd  
address. You are seeing an echo of that fact, all these years later.

Subsequent processors have been almost completely tolerant of  
misaligned loads and stores. By tolerant, I mean that the program  
doesn't crash.  But performance suffers, sometimes very badly, unless  
variables are placed at addresses in RAM that are a multiple of their  
size ("natural alignment").

Type        Size  Natural Alignment
----        ---- -----------------
byte          1   any
short         2   even address
long, single  4   address divisible by 4
double        8   address divisible by 8

The load-store unit of PPC processors works most efficiently when all  
memory accesses are aligned in this way. Natural alignment of  
ordinary variables (i.e. not part of a record structure) is enforced  
by the FB compiler if you turn on the checkbox:
    Preferences > Advanced > Align on proper boundaries
In my opinion, all FB programmers should turn this preference on.


And yes, turning the preference on will eliminate the warning that  
you are seeing.

Robert P.