Thread: typedef struct from .h and .c

  1. #1
    Registered User
    Join Date
    Oct 2008
    Location
    CA
    Posts
    19

    typedef struct from .h and .c

    Hello,

    Here is my problem:

    I declare the vector struct in my .h file and then try to access its fields in the .c file. I did declare a variable of type vector. However, I get a compiler error saying that 'vector has no member named' [x] where x is the fields I defined in my struct. Here is my struct def in the .h file:
    Code:
    typedef struct {
    void* elems;
    int elemSize;
    int logLength;
    int allocLength;
    } vector;
    Thanks!
    Liz
    Last edited by Salem; 10-16-2008 at 11:16 PM. Reason: added code tags - learn to use them yourself

  2. #2
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    I'd have to see your .c code as well. Since so far, you haven't declared much of anything. Just a typedef.

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    I like guessing: you are using -> when the left side is not a pointer (in which case you just use .), or vice versa.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error: redefinition of typedef xxxx
    By Rocha in forum C Programming
    Replies: 2
    Last Post: 11-24-2008, 09:19 AM
  2. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  3. .h file vs .c file
    By RocketMan in forum C Programming
    Replies: 5
    Last Post: 05-13-2008, 07:28 PM
  4. Replies: 4
    Last Post: 12-14-2005, 02:21 PM
  5. Difference between .h and .c files
    By Metalix in forum C Programming
    Replies: 9
    Last Post: 01-19-2005, 08:38 PM

Tags for this Thread