I would hazard a guess that your buf randomly points to some useful
memory in one compile and not in the other. Try setting it to point
to an element of whatever your struct is before using it.
MS
Jun Zhang wrote:
> Thanks for relay, Michael.
>
> The problem I have is the pointer is work properly on the following version
> if ( flag & 0x01)
> {
> buf[i].target = table[i].some_double;
> buf[i].nexthop = table[i].some_int;
> }
>
> but if I use flag == 1 instead of flag & 0x01 cause this problem.
>
> and as my understand is set the pointer buf[0].target to memory address
> of some_double? ;)
>
> thanks million
>
> 2009/8/31 Michael Schippling <[email protected] <mailto:[email protected]>>
>
> That sets something at i elements from the start of buf to
> some_double, however I didn't see a place where you set buf
> itself to point to anything that might hold i elements (I can't
> parse the code in the message w/o CR's so I'm extemporizing here):
>
> BUFTYPE bunchaElements[100];
> BUFTYPE *buf = bunchaElements;
>
> See this for a pretty good discussion:
> http://en.wikibooks.org/wiki/C_Programming/Pointers_and_arrays
>
> MS
>
>
> Jun Zhang wrote:
>
> buf[i].target = table[i].some_double;
>
> this code is not set pointer to some value?
> thanks
>
> 2009/8/29 Michael Schippling <[email protected]
> <mailto:[email protected]> <mailto:[email protected]
> <mailto:[email protected]>>>
>
>
> You don't seem to have set buf to point to anything...
> MS
>
> Jun Zhang wrote:
>
> Hello, everyone. I am new to tinyos and nesc. and I have the
> following data strucuture typedef nx_struct rt_link {
> nx_addr_t
> target; nx_addr_t nexthop; } rt_link_t; typedef struct
> rt_entry
> { double some_double; uint8_t some_int; } rt_entry_t;
> uint8_t
> flag = 0x01; uint8_t i=0; rt_link_t * buf; rt_entry_t
> table[10];
> if ( flag & 0x01) { buf[i].target = table[i].some_double;
> buf[i].nexthop = table[i].some_int; } and if I use if (
> flag ==
> 1) { buf[i].target = table[i].some_double; buf[i].nexthop =
> table[i].some_int; } I will get different value from buf[0],
> whats the difference?
> -- Kind Regards
>
> Jun
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> <mailto:[email protected]>
> <mailto:[email protected]
> <mailto:[email protected]>>
>
>
>
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
>
>
>
> --
> Kind Regards
>
> Jun
>
>
>
>
> --
> Kind Regards
>
> Jun
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help