Re: Conflicting data structures. [message #38234] |
Fri, 27 February 2004 08:31 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Nuno Oliveira writes:
> I have I problem, and perhaps you can help...
>
> I have pointer of structures. I defined in the main program as Data =
> ptr_new(/allocate_heap)
>
> And the when the user starts to generate events I have a structure like
> this. I made it an isolated function just to avoid problems with
> defining structures, but it still does. How is this possible?
>
> PRO Add_NewStrct, s
> new_strct = {tag1: name, tag2: array, tag3: ptr_new(/allocate_heap)}
> new_strct.tag3 = Result_of_a_function()
> ;if it matters is the result is a pointer do pointers
>
> if n_elements(*s.Data) eq 0 $
> then *s.Data = new_strct $
> else *s.Data = [*s.Data, new_strct]
>
> return, s
> end
>
> The error idl indicates is: data conflicting strucutures <ptrHep xyz>
> new_strct
>
> I tought once the function is finished he would loose previuos
> information about the strcuture? But it seems that's not it.
> I was looking in old questions here, and I tried to use ptr_free for
> that tag3, but I had the same problem again...
The answer is that anonymous structures have "secret" names, which
keeps them from being concatenated in this way. Here is an article
to read:
http://www.dfanning.com/tips/concatenate_structs.html
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|