Thread: Errors in compile

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    12

    Errors in compile

    am im missing something stupid?
    Last edited by micmac700; 09-24-2006 at 06:41 PM.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    You're defining a struct, not a variable. It can't be an array. Perhaps something more like this:
    Code:
    struct tty {
    	Queue readQ, writeQ, echoQ;
    	int echoflag;
    };
    
    struct tty ttytab[NTTYS];
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    12
    with that fix i get this error


    tty.c:232: warning: file does not end in newline
    tty.c:18: redefinition of `struct tty'

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >tty.c:232: warning: file does not end in newline
    Put your cursor after the last character in the file and hit Enter.

    >tty.c:18: redefinition of `struct tty'
    Post your code, please.
    My best code is written with the delete key.

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    12
    This is the original
    Last edited by micmac700; 09-24-2006 at 06:41 PM.

  6. #6
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    Code:
    typedef struct tty {
    	Queue readQ, writeQ, echoQ;
    	int echoflag;
    }MyTtl;
    
    MyTtl ttytab[NTTYS];
    try that. It shouldn't make a difference though

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    12
    got:
    tt
    Last edited by micmac700; 09-24-2006 at 06:41 PM.

  8. #8
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >got:
    When I asked for code, I meant more than what you originally offered. Shrink your program down to something small that still gives you the errors and then cut and paste the entire files. Most of the time, having just the error is useless in debugging. You need both the error and all of the code around the line that the error refers to.
    My best code is written with the delete key.

  9. #9
    Registered User
    Join Date
    Sep 2006
    Posts
    12
    and the struct tty that I am adding
    Last edited by micmac700; 09-24-2006 at 06:40 PM.

  10. #10
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >and the struct tty that I am adding queues to is from file tty.c right after the includes
    It should be the struct tty that's already defined in tty.h. It sounds like you're adding another definition, which coincides with the error you're getting.
    My best code is written with the delete key.

  11. #11
    Registered User
    Join Date
    Sep 2006
    Posts
    12
    yea im confused on C, still learning.
    Last edited by micmac700; 09-24-2006 at 06:40 PM.

  12. #12
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >So i'm not sure what to do with the ttytabs array
    Leave it as is. You only need to change the definition of the structure, not any variables of the structure. Of course, how the variables are used will likely change, but that's not relevant to this particular problem.
    My best code is written with the delete key.

  13. #13
    Registered User
    Join Date
    Sep 2006
    Posts
    12
    so should it be
    Last edited by micmac700; 09-24-2006 at 06:40 PM.

  14. #14
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Don't worry about the typedef. Just this:
    Code:
    struct tty {
    	Queue readQ, writeQ, echoQ;
    	int echoflag;
    };
    And be aware that if that's the only change to the code you've linked to, you'll get slews of errors because the members of the tty struct have changed. So please don't come running to us when you get stuff like "rbuf undeclared identifier", k?
    My best code is written with the delete key.

  15. #15
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > Last edited by micmac700 : Today at 01:40 AM.
    Please don't edit your posts down to nothing when you feel you've got an answer.

    Not only does it make following replies look stupid, there is no way for people who come along later to get any idea of what the hell's going on.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange compile errors
    By csonx_p in forum C++ Programming
    Replies: 10
    Last Post: 07-28-2008, 11:41 AM
  2. compile once, compile twice ...error
    By Benzakhar in forum Windows Programming
    Replies: 6
    Last Post: 12-28-2003, 06:00 AM
  3. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  4. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 01:43 PM