OCCRA
Go to Post Hi. My name is Rick and I am a Roboholic. - Rick TYler [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Events   CD-Media   CD-Spy   FRC-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-16-2004, 05:28 PM
Jeff McCune's Avatar
Jeff McCune Jeff McCune is offline
Alpha Geek
#0677 (The Wirestrippers)
Team Role: Mentor
 
Join Date: Jan 2003
Location: The Ohio State University
Posts: 67
Jeff McCune is on a distinguished road
Send a message via ICQ to Jeff McCune Send a message via AIM to Jeff McCune
Pointers to structs?

I'm trying to abstract relays into a structure with a forward and reverse element. The idea is to have a single set_relay() funtion that takes a pointer to this data structure as it's input.

I can't figure out how to get mcc to accept my syntax. I've been referencing a lot of documents, so I'm pretty sure my syntax is correct, but I haven't verified it with gcc or what not. I'm going to go do that now and then post some of my example code. Was just wondering if there's problems to start with though.
__________________
Team 677 - The Wirestrippers - Columbus School for Girls and The Ohio State University
EMAIL: mccune@ling.ohio-state.edu

...And all you touch and all you see
Is all your life will ever be...
  #2   Spotlight this post!  
Unread 02-16-2004, 05:39 PM
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 7,842
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Pointers to structs?

We had this discussion (well, not really a discussion, but a comment) in another thread. http://www.chiefdelphi.com/forums/sh...9&postcount=19

depending on how you are doing it, you may need to make your own macros.
  #3   Spotlight this post!  
Unread 02-17-2004, 12:17 PM
Jeff McCune's Avatar
Jeff McCune Jeff McCune is offline
Alpha Geek
#0677 (The Wirestrippers)
Team Role: Mentor
 
Join Date: Jan 2003
Location: The Ohio State University
Posts: 67
Jeff McCune is on a distinguished road
Send a message via ICQ to Jeff McCune Send a message via AIM to Jeff McCune
Re: Pointers to structs?

After some testing in gcc, I figured it out. The more descriptive errors helped. The page I was reading was incorrect about the ordering of the type name versus the variable name. I'm actually passing a bitmask value that I #defined as a bitmask, but I just did it this way so it's easier for people to understand the pointer stuff that's going on. It's so nice having full ansi C.

Code:
struct relay_type { int fwd; int rev};
struct relay_type ball_arm_lower;

void set_relay (struct relay_type *relay, int fwd, int rev)
{
  relay->fwd = fwd;
  relay->rev = rev;
}

main()
{
  update_inputs ();
  set_relay (&ball_arm_lower, 1, 0);
  update_outputs ();
}
__________________
Team 677 - The Wirestrippers - Columbus School for Girls and The Ohio State University
EMAIL: mccune@ling.ohio-state.edu

...And all you touch and all you see
Is all your life will ever be...
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Laser Pointers.. archiver 2001 18 06-23-2002 11:08 PM


All times are GMT -5. The time now is 06:52 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi