I'm passing an std::string to a function imported from boost-program-options dll. The function takes one parameter and it's a const reference to a string. However, the value that the function receives is different from what I pass. Here's the minimal code
#include "boost/program_options.hpp"
int main()
{
std::string s = "This is a string";
auto res = boost::program_options::to_internal(s);
}
And here's the function
BOOST_PROGRAM_OPTIONS_DECL std::string to_internal(const std::string& s)
{
return s;
}
The value of the parameter "s" is supposed to be "this is a string" when the function above is called, but the value is always something different. When I say something different I mean a long random string. So long that the basic_string constructor throws an exception.
My only guess is that it has something to do with how the function is called and how the parameters are passed since this function is imported from an external dll.
I followed the macro BOOST_PROGRAM_OPTIONS_DECL definition and it's just __declspec(dllimport)
More info:
- standard is C++14
- Toolset used is Visual studio 2019 v142
- Boost library version is 1.73.0 and installed using vcpkg