More mixed class library questions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ajtaylor@hushmail.com

    More mixed class library questions

    I have a large amount of C++ unmanaged code that I am attempting to use
    in a managed project.

    Amongst this code is a large number of classes and structs that I would
    like to be able to use in several projects in the solution.

    (my logic is that I am making my solution a more component based
    approach and using managed code where its best and keeping the
    unmanaged code at the back end)

    I tried to create a class library project that contains all these
    common structs/classes and that works fine.

    When I include it in another project using #using I cant see any of
    these structs/classes - I am assuming that is because this code is
    unamanged C++.

    So do I simply have to share the relevant .h/.cpp files amongst the
    projects or is there a way or using these types in an assembly and
    using that?

    I apologise if this is a silly question but there is a definite lack of
    documentation out there on C++/CLI IMHO.

  • Bruno van Dooren [MVP VC++]

    #2
    Re: More mixed class library questions

    I tried to create a class library project that contains all these
    common structs/classes and that works fine.
    >
    When I include it in another project using #using I cant see any of
    these structs/classes - I am assuming that is because this code is
    unamanged C++.
    Yes, they don't show up with the #using directive.
    So do I simply have to share the relevant .h/.cpp files amongst the
    projects or is there a way or using these types in an assembly and
    using that?
    Only the .h files. Be sure to separate managed and unmanaged stuff in
    different .h files, because
    otherwise you can get problems when managed stuff is seen by the compiler in
    both the .h file and in the assembly that you are #using

    You also have to use __declspec(dlle xport) on the unmanaged classes /
    structs that you want to export.

    --

    Kind regards,
    Bruno van Dooren
    bruno_nos_pam_v an_dooren@hotma il.com
    Remove only "_nos_pam"


    Comment

    Working...