Find the answer to your Linux question:
Results 1 to 3 of 3
Can anyone please explain what's wrong with the following: In header file control.h I have prototype:- /* Toggle relay */ int toggle_relay(relays *); In source file tsc_ctrl.c I have:- typedef ...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Location
    On the bay, Morecambe Bay.
    Posts
    15

    pointer to struct argument

    Can anyone please explain what's wrong with the following:

    In header file control.h I have prototype:-
    /* Toggle relay */
    int toggle_relay(relays *);

    In source file tsc_ctrl.c I have:-
    typedef struct {
    int addr; /* Base Address for I/O */
    int offset; /* Base offset */
    int num; /* Relay number */
    int state; /* ON/OFF */
    int type; /* Valve; Switch; . . .*/
    char label[20]; /* Device name e.g. LP_PUMP */
    } relays;

    relays relay[20];

    When I compile this program I get the error message:-
    In file included from tsc_ctrl.c:23:
    control.h:34: error: parse error before '*' token

    What is wrong with the prototype?
    How do I pass a pointer to the type 'relays' to a function??

  2. #2
    Linux User
    Join Date
    Jan 2006
    Posts
    414
    looks like you're trying to use the type relays before declaring it.

  3. #3
    Just Joined!
    Join Date
    Jan 2009
    Location
    On the bay, Morecambe Bay.
    Posts
    15
    Quote Originally Posted by darkrose0510 View Post
    looks like you're trying to use the type relays before declaring it.
    looks like you're right, you clever person you!!! Thank you for that, much appreciated.
    Can I propose you venture into re-writing compiler error messages?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...