CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2005
    Posts
    159

    Question Static library design advise needed

    Dear all,

    I'm currently setting up a project which will need to run on both win32 and wince. A lot of code will be common, but a substantial part will also be specific depending on the platform. Part of the common code is a communication stack. To keep things separated and manageable I though it would be a good idea to put the stack in a static library. The stack consists of a lot of classes that are interconnected but that don't really matter to the 'user' of the stack, so I would only offer those header files that the 'user' might need.

    I suppose, so far so good, please correct me if I'm wrong, or if you'd have a better idea.

    The tricky part is that the communication stack needs timers, and the implementation of those is platform specific. My current approach is to write the timer header file in the library project and export it together with the library. The implementation file should then be in the platform specific project.

    My questions:
    • If I export the header files of only a couple of classes they will obviously show some implementation details that the 'user' of the library doesn't need to know about (everything that is private in those exported classes for example). How is this usualy hidden / done?
    • Is my timer implementation a good idea? To me it feels somewhat strange but I can't seem to find a better solution. The code inside the library needs functionallity that is platform specific, but at the same time the library cannot contain anything platform specific.

    I look forward for your ideas.

    thank you,
    Jef

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Static library design advise needed

    Quote Originally Posted by Jef Patat
    If I export the header files of only a couple of classes they will obviously show some implementation details that the 'user' of the library doesn't need to know about (everything that is private in those exported classes for example). How is this usualy hidden / done?
    If this is a concern, maybe the pointer to implementation (pimpl, a.k.a. opaque pointer) idiom will be applicable.

    Quote Originally Posted by Jef Patat
    Is my timer implementation a good idea? To me it feels somewhat strange but I can't seem to find a better solution. The code inside the library needs functionallity that is platform specific, but at the same time the library cannot contain anything platform specific.
    Don't see a problem here. You are specifying an interface, coding to that interface, then implementing the interface as needed.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured