I have written a sample static library.
I want to suppress the implicit instantiation of std::string/std::wstring. I referred this link and I declared the explicit instantiation of template class std::basic_string. I expected that the static lib wont contain any symbols for std::basic_string. But the dumpbin utility showed there are symbols present for basic_string in the library. The code is as follows:
// testLib.h   
#pragma once
namespace staticLib{
    void TestLib();
}
// testLib.cpp  
#include < string >     
#include "testLib.h";
//Explicit instantiation declaration   
extern template class std::basic_string< char> ; // Is this correct?
namespace staticLib {
    void TestLib() {
        std::string str = "Testing";
        str.size();
        str.erase();
    }
}
My questions are as follows:
- Is there any way to suppress the implicit instantiation of std::string/std::wstring.
 - There is an 'explicit instantiation declaration for std::basic_string' in testLib.cpp. Is that correct ?
 - Why the declaration of explicit instantiation of basic_string does not prevent the implicit instantiation and the symbols in the library.
 

Aucun commentaire:
Enregistrer un commentaire