const array member address?

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

const array member address?

Post by Jerry Messina » Sat Apr 06, 2013 1:36 pm

Is there an optimal way of directly getting the address of a const array element that has a fixed index?

I've tried

Code: Select all

const c(10) as word = (1,2,3,4,5,6,7,8,9,10)

dim addr as word

// trying to get the address of array element(1)
addr = addressof(c(1))     // error... "Expression cannot be passed by reference"

// all of these work, but they generate code to compute the address
addr = addressof(c) + sizeof(c(0))
addr = addressof(c) + sizeof(word)
addr = addressof(c) + 2

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Sat Apr 06, 2013 5:32 pm

The ways you have shown are pretty much the only way to get @c(1)

Post Reply