digitalmars.D - Q: Is there a (different) work-around for AA.keys problems?
- Austin Hastings <ah08010-d yahoo.com> Jan 29 2011
- Adam D. Ruppe <destructionator gmail.com> Jan 29 2011
- Austin Hastings <ah08010-d yahoo.com> Jan 29 2011
Howdy,
I'm jammed up against a variation of the issue#3745/3770 AA linkage problem.
In my case, I'm using an int[ string ] AA, and I'm getting the dreaded
Error 42: Symbol Undefined
_D6object28__T16AssociativeArrayTAyaTiZ16AssociativeArray4keysMFNdZAAya
My code looks something like:
class gc_enum : subscriber
{
int[ string ] gc_label_index;
// ...
void assign_gc_enum_vals( )
{
sorted_labels = gc_label_index.keys;
sorted_labels.sort;
// ...
}
Looking in the rtl sources, I don't see that function in aaA.d. Maybe
it's in a different file, or maybe the compiler is supposed to magically
rewrite those accesses into something totally different.
I've been trying to get all my code into a single file, as that seems to
be a work-around, but I'm wondering if there are other ways to work
around this problem?
Thanks,
=Austin
Jan 29 2011
Shooting in the dark here (I can't reproduce the error for
whatever reason), but for similar problems, I've found this fixes
it:
Add a function somewhere in your file that says:
void hackAroundBug() {
writeln(typeid(int[string]));
}
You never actually need to call it. Just putting it there gives
the compiler that extra nudge to put the symbol back into the
object file.
The error I saw was related to .rehash being missing, but it
fixed it for me and might work here too.
My older method was to add
-I/home/me/d/dmd2/src/druntime/src /home/me/d/dmd2/src/druntime/src/object_.d -d
On to the DMD command line (object_.d has the code needed for
various AA things). Of course remember to fix the paths there
to your dmd source.
But with the referencing typeinfo workaround, I haven't needed
to do this at all anymore.
Jan 29 2011
The hackAroundBug()/typeid approach didn't work for me - I still got the
error 42. Presently, I'm using a local method, but this is annoying for
obvious reasons:
string[] aa_keys( int[ string ] aa )
{
return aa.keys;
}
Even more annoying is that this works, while a simple reference to the
member.keys in the calling method doesn't. I wonder if this is caused by
the AA being inside an object?
=Austin
On 1/29/2011 11:17 AM, Adam D. Ruppe wrote:
Shooting in the dark here (I can't reproduce the error for
whatever reason), but for similar problems, I've found this fixes
it:
Add a function somewhere in your file that says:
void hackAroundBug() {
writeln(typeid(int[string]));
}
You never actually need to call it. Just putting it there gives
the compiler that extra nudge to put the symbol back into the
object file.
The error I saw was related to .rehash being missing, but it
fixed it for me and might work here too.
My older method was to add
-I/home/me/d/dmd2/src/druntime/src /home/me/d/dmd2/src/druntime/src/object_.d
-d
On to the DMD command line (object_.d has the code needed for
various AA things). Of course remember to fix the paths there
to your dmd source.
But with the referencing typeinfo workaround, I haven't needed
to do this at all anymore.
Jan 29 2011








Austin Hastings <ah08010-d yahoo.com>