Thread: declaration issues

  1. #1
    Registered User
    Join Date
    Jan 2008

    declaration issues


    I have just come across an issue that i am just not able to understand..
    i have declared a structure in one of .c files ..

    struct fun {
        char var1;
        int var 2;
        struct fun *next 
    now what i have done is i have made a header file and put a typedef like:

    typedef struct fun morefun
    and GOD KNOWS how the header file is able to know that the structure has been defined in the other file..and code is compiling with not even a single warning..

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    What does the code that uses morefun look like? If it's only using morefun as a pointer, and never accessing it's content, then you only need to tell the compiler that it's "some sort of struct called fun", which is what you have done.

    The code will not compile if it's accessing members of a struct that hasn't been declared. No doubt about this.

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  2. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM