Modernizing C++ code

27 page views   |   124 words   |  
Today at work I had fun upgrading an older corner of our codebase that was written in C++. The goal is to get rid of the deprecated CURLOPT_PROTOCOLS integer and replace it with the CURLOPT_PROTOCOLS_STR interface. Where it got interesting is how the libcurl API expected a naive C string (char *), but the whole C++ codebase surrounding it's usage used std::string. I got the code building, updated it, but I'm running into an interesting edge case where the reinterpret_cast type conversion is not copying the protocols string.

auto test_impl = reinterpret_cast<curl_impl* const>(handle);

reinterpret_cast is a very special and dangerous type of casting operator[1]
wish me luck

UPDATE (2024-01-16) the reinterpret_cast was a red herring. I figured out the issue.

#programming #c++