|
Page 1 of 1
|
[ 4 posts ] |
|
Is it possible to compare references ?
| Author |
Message |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2864 Location: Rotterdam, The Netherlands
|
 Re: Is it possible to compare references ?
Hi Miki,
You might be able to do with your own homebrew version of memcmp(). There is currently no native way of doing this, though.
I'll send a mail tot he devs to ask if it is possible to implement this.
- Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Sat Jan 21, 2012 6:58 am |
|
 |
|
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 495
|
 Re: Is it possible to compare references ?
I don't think that even ANSI C offers intelligent comparison of structs. As Xander said, you should be able to accomplish this by writing a function similar to equalsTo() in Java. Compare the structs member by member: I don't know how you plan on determining the size of the Point array, so I just threw in a parameter. EDIT: Sorry, posted just after the above post and didn't read it carefully.
_________________ sudo rm -rf /
|
| Sat Jan 21, 2012 8:37 am |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: Is it possible to compare references ?
I attempted to write code to compare the "reference" passed to a function. This is so that the function knows which instance it is and can do different things accordingly. But it didn't work. If RobotC had pointer support, this is totally straight forward. Like I said, I tried it last year and it did not work. Now that we have 3.05 and it seems it has partial support of pointers, I am wondering if you can do that now. In any case, I get around this problem by adding an "instance ID" in the structure.
|
| Sun Jan 22, 2012 12:31 am |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2864 Location: Rotterdam, The Netherlands
|
 Re: Is it possible to compare references ?
Looks like memcmp() has been implemented for the next release  You could easily implement a compare function with memcmp() if you have a unique identifier member for each object. - Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Sun Jan 22, 2012 2:47 am |
|
|
|
Page 1 of 1
|
[ 4 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|