Thread: external user defined types

  1. #1
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459

    external user defined types

    [continuation from external classes ]

    to broaden the question... can i use the extern keyword for userdefined types? apparently it doesn't work... [with classes at least]... i'm using DJGPP... thank you very much...
    hasafraggin shizigishin oppashigger...

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You can't extern declarations. For instance, it wouldn't make any sense to do -

    extern int;

    You have to extern objects/instances of types -

    class MyClass
    {
    public:
    int b;
    };

    extern MyClass c;
    extern int a;
    //etc

    extern isn't used to enlarge the scope of declarations (that's why you include header files), but to share variables between files.
    zen

  3. #3
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    so since i can't do that... that means that i'll have to either seperate the class declarations and poly-include them [so i only have one floating copy] or i'll have to create another copy...

    that's what i had going for me before, but now that i've reorganized my huge nested class structure [meanwhile raising the kb/srcfile from 2 kb per to 6 kb per...] i'll have to go back to the way i had it before... is there an alternative if i still want seperate compilation? right now it's working since i'm not using seperate compilation... [granted, it's not really a necessity to have linking, since compile time isn't _that_ large at all... but it was back in the old day when my system was slower...]

    thanks for your time...
    hasafraggin shizigishin oppashigger...

  4. #4
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    is there an alternative if i still want seperate compilation?
    No, you'll have to put the class declaration in a header file and include it in every file that uses an instance of the class.

    However, you only have to put the declaration in the header file and not the definition of all the class member functions (unless you're inlining or using templates). The member definitions can go in their own cpp file which you wont have to include. Unless you've got a very large class declaration, it shouldn't add 4kb to each source file it's included in.
    zen

  5. #5
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    yeah, gotcha... what i'll probably do is put _all_ of the class declarations [since it is a nested class structure] in one file... and leave the seperate function definitions per class... that way my average won't decrease that much, and i have one header i can poly include per source file...

    PS, what's the term for all the code that produces one object file? if i say 'source file', like i just did, it could mean just one file which is necessarily the whole object source code included in that object file... thanks alot...
    hasafraggin shizigishin oppashigger...

  6. #6
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    PS, what's the term for all the code that produces one object file?
    Translation unit.
    zen

  7. #7
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    thanks! say, do you have an AIM handle or MSN handle zen? myne is doubleanti
    hasafraggin shizigishin oppashigger...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Reading User Defined Files
    By Necrofear in forum C++ Programming
    Replies: 17
    Last Post: 06-30-2006, 12:55 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. SSH Hacker Activity!! AAHHH!!
    By Kleid-0 in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 03-06-2005, 03:53 PM
  5. Header files
    By borland_man in forum C++ Programming
    Replies: 14
    Last Post: 02-22-2002, 04:30 AM