Does it make sense to export a template class def?

Discussion in 'C++' started by Ben, Aug 8, 2003.

  1. Ben

    Ben Guest

    Hi.

    I am currently trying to move compilers (VC6 -> VC7 in fact) and I'm
    having a few problems (so far exclusively to do with better standard
    conformance).

    Anyhow, whilst rebuilding a third-party library (let's call it library
    B) I'm getting some unresolved externals when it tries to use another
    library (library A) that includes code like this in a header:

    template<class T>
    class EXPORT AClassName
    {
    ...
    };


    (BTW: EXPORT is defined as __declspec(dllexport) or
    __declspec(dllimport) depending on which lib I'm building.)

    I first assumed that library A wasn't actually exporting the class
    (some screw-up with the def of EXPORT I thought). But after checking
    that was OK I realised (doh!) that this is template class and
    therefore all members are fully defined in the header file.

    So this made we wonder - why might the above class have the EXPORT
    keyword in there at all? Surely it's redundant for a template class?

    Confused,
    Ben.
    Ben, Aug 8, 2003
    #1
    1. Advertising

  2. "Ben" <> wrote in message
    news:...
    > Hi.
    >
    > I am currently trying to move compilers (VC6 -> VC7 in fact) and I'm
    > having a few problems (so far exclusively to do with better standard
    > conformance).
    >
    > Anyhow, whilst rebuilding a third-party library (let's call it library
    > B) I'm getting some unresolved externals when it tries to use another
    > library (library A) that includes code like this in a header:
    >
    > template<class T>
    > class EXPORT AClassName
    > {
    > ...
    > };
    >
    >
    > (BTW: EXPORT is defined as __declspec(dllexport) or
    > __declspec(dllimport) depending on which lib I'm building.)
    >
    > I first assumed that library A wasn't actually exporting the class
    > (some screw-up with the def of EXPORT I thought). But after checking
    > that was OK I realised (doh!) that this is template class and
    > therefore all members are fully defined in the header file.
    >
    > So this made we wonder - why might the above class have the EXPORT
    > keyword in there at all? Surely it's redundant for a template class?



    Either because someone writing this did not understand templates well
    enough, or I am missing something. I would not bother and just remove the
    EXPORT part from the template. The class is defined as if it was your own,
    no need to put any stuff around it.

    hth
    --
    jb

    (replace y with x if you want to reply by e-mail)
    Jakob Bieling, Aug 8, 2003
    #2
    1. Advertising

  3. Ben

    Ben Guest

    > Either because someone writing this did not understand templates well
    > enough, or I am missing something. I would not bother and just remove the
    > EXPORT part from the template. The class is defined as if it was your own,
    > no need to put any stuff around it.
    >
    > hth


    Looks like it's the former - I tried just removing the export def and
    all seems well.

    Cheers for the confirmation!

    Ben
    Ben, Aug 9, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jiong Feng
    Replies:
    0
    Views:
    798
    Jiong Feng
    Nov 19, 2003
  2. Sean Ross
    Replies:
    3
    Views:
    110
    Aredridel
    Dec 25, 2003
  3. Replies:
    7
    Views:
    144
  4. planetthoughtful

    Newbie: def must come before call to def?

    planetthoughtful, Mar 12, 2007, in forum: Ruby
    Replies:
    4
    Views:
    118
    Pit Capitain
    Mar 12, 2007
  5. Kyung won Cheon
    Replies:
    0
    Views:
    185
    Kyung won Cheon
    Nov 21, 2008
Loading...

Share This Page