Reputation: 23
Suppose there are followings hierachi my shared library source.
MySharedLibraryData.h
#define DATA_TYPE (1)
MySharedLibrary.h
#include "MySharedLibraryData.h"
void FuncA();
MySharedLibrary.cpp
#include "MySharedLibrary.h"
#include "MySharedLibraryPrivate.h"
void FuncA(){ MySharedLibraryPrivate.FuncCore(DATA_TYPE); }
MySharedLibraryPrivate.h
void FuncCore(int dataType);
MySharedLibraryPrivate.cpp
void FuncCore(int dataType) { //do something using core logic; }
Case A) Do I need to provide libMySharedLibrary.so and MySharedLibrary.h, MySharedLibraryData.h to library user?
or
Case B) Do I need to provide libMySharedLibrary.so and MySharedLibrary.h, MySharedLibraryData.h and MySharedLibraryPrivate.h to library user?
which one is right?
I thought that I need to provide like Case A). is it wrong? If so, why?
Upvotes: 0
Views: 212
Reputation: 15164
You should distribute what is needed to use the library and nothing else. Doing that will also help ensure a stronger division between private and public headers, in that you should create a test project that only has access to the public header and make sure that no dependencies on the private header are present.
Upvotes: 1
Reputation: 10827
You should not provide MySharedLibraryPrivate.h
and you should not have either of the headers in the public interface MySharedLibraryData.h
or MySharedLibrary.h
include the private header. This would defeat the purpose of having a private header.
Upvotes: 0