|
From: willhouse86 on 15 Jan 2008 12:17 Hello, I'm creating a "wrapper" library interface for a third party library. One of my reasons for designing such an interface is to remove the third party header file dependency for users of my library. I am able to do this by using only references to the third party library objects in my header files and forward declaring the corresponding classes. In some cases, the third party library uses one of their typedefs for an STL container of pointers. I'm able to include the header for the container (<vector>) and forward declare the pointer classes to avoid the inclusion of the third party header file(s), but in doing so I am ignoring the typedef used by their code. Is this considered bad practice? willhouse
From: James Dennett on 15 Jan 2008 14:00 willhouse86(a)gmail.com wrote: > Hello, > > I'm creating a "wrapper" library interface for a third party library. > One > of my reasons for designing such an interface is to remove the third > party header file dependency for users of my library. I am able to do > this by using only references to the third party library objects in my > header files and forward declaring the corresponding classes. > > In some cases, the third party library uses one of their typedefs for > an STL container of pointers. I'm able to include the header for the > container (<vector>) and forward declare the pointer classes to > avoid the inclusion of the third party header file(s), but in doing so > I am ignoring the typedef used by their code. Is this considered > bad practice? There's no trivial answer: this can be problematic. It might be OK, or you might be better off completely wrapping their header file with your own interface so that there's doesn't "leak through" at all. -- James
From: Jim Langston on 15 Jan 2008 18:58 willhouse86(a)gmail.com wrote: > Hello, > > I'm creating a "wrapper" library interface for a third party library. > One > of my reasons for designing such an interface is to remove the third > party header file dependency for users of my library. I am able to do > this by using only references to the third party library objects in my > header files and forward declaring the corresponding classes. > > In some cases, the third party library uses one of their typedefs for > an STL container of pointers. I'm able to include the header for the > container (<vector>) and forward declare the pointer classes to > avoid the inclusion of the third party header file(s), but in doing so > I am ignoring the typedef used by their code. Is this considered > bad practice? A pointer is one of the things that can usually be safely forward declared without having to include the complete specification. If the user has no need for the details of what the pointer is pointing to, this is probably fine and desirable. No need to expose the internal workings uneccesarrily. -- Jim Langston tazmaster(a)rocketmail.com
|
Pages: 1 Prev: equation to C++ Next: Implementation question on template functions |