cppfs icon indicating copy to clipboard operation
cppfs copied to clipboard

Remove std templates from interface

Open lppinto opened this issue 4 years ago • 2 comments

I would remove std::string (and other templates) from the interface and would replace it with const char* when returning for example the file name, etc. I believe this might be problematic if one tries to link a debug library with the release version of the cppfs

lppinto avatar May 25 '20 15:05 lppinto

I believe this is related to some warnings I'm getting from VisualStudio:

2>vcpkg\installed\x64-windows\include\cppfs/FilePath.h(348,23): warning C4251: 'cppfs::FilePath::m_path': class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'cppfs::FilePath'
2>F:\Programs\VisualStudio\VC\Tools\MSVC\14.26.28801\include\xstring(4575): message : see declaration of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>'
2>vcpkg\installed\x64-windows\include\cppfs/FilePath.h(352,35): warning C4251: 'cppfs::FilePath::m_fullPath': class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'cppfs::FilePath'
2>F:\Programs\VisualStudio\VC\Tools\MSVC\14.26.28801\include\xstring(4575): message : see declaration of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>'
2>vcpkg\installed\x64-windows\include\cppfs/FilePath.h(353,35): warning C4251: 'cppfs::FilePath::m_filename': class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'cppfs::FilePath'
2>F:\Programs\VisualStudio\VC\Tools\MSVC\14.26.28801\include\xstring(4575): message : see declaration of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>'
2>vcpkg\installed\x64-windows\include\cppfs/FilePath.h(354,35): warning C4251: 'cppfs::FilePath::m_basename': class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'cppfs::FilePath'
2>F:\Programs\VisualStudio\VC\Tools\MSVC\14.26.28801\include\xstring(4575): message : see declaration of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>'
2>vcpkg\installed\x64-windows\include\cppfs/FilePath.h(355,36): warning C4251: 'cppfs::FilePath::m_extension': class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'cppfs::FilePath'
2>F:\Programs\VisualStudio\VC\Tools\MSVC\14.26.28801\include\xstring(4575): message : see declaration of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>'
2>vcpkg\installed\x64-windows\include\cppfs/FilePath.h(356,40): warning C4251: 'cppfs::FilePath::m_directoryPath': class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'cppfs::FilePath'
2>F:\Programs\VisualStudio\VC\Tools\MSVC\14.26.28801\include\xstring(4575): message : see declaration of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>'
2>vcpkg\installed\x64-windows\include\cppfs/FilePath.h(357,38): warning C4251: 'cppfs::FilePath::m_driveLetter': class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'cppfs::FilePath'
2>F:\Programs\VisualStudio\VC\Tools\MSVC\14.26.28801\include\xstring(4575): message : see declaration of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>'

I'm sort of confused why the error is showing up when I'm building an executable, not a dll, and C4251 seems to explicitly be about dll compilation. It isn't hurting me, but warnings are annoying.

Caldfir avatar Jul 08 '20 04:07 Caldfir

If some include prototypes declares a class that has public or even private stl members, this might be the case… I for once would use the pimpl pattern to hide those complex members that don't have dll interface exports (stl templates) and would substitute those with getters to get more simplified types (std::string -> const char*)

lppinto avatar Jul 09 '20 11:07 lppinto