Yes, my code has everything to do with that Microsoft SQLDriverConnect, I am trying to compile the skeleton for the ODBC driver.
What is the best way to cast an unsigned char* to char*? The reinterpret cast allows me to compile, but will it work at run time? Or should I use C-style or function cast?
reinterpret_cast<char*>(ptrConnStrIn)
Also, for the information of beginners like myself, the mistakes I have been making are:
1) parameters are passed by value, so that the purpose of the const is to ensure that you can pass values to a function that are not alterable by the function.
2) because of 1), the pointer that is being passed 'ptrConnStrIn' is const by default i.e. strlen only gets a copy
3) the definition of the strlen argument in <string.h> is _In_z_ char const* _Str. That does not mean that it expects a pointer constant, which would be unnecessary since it only gets a copy of the pointer anyway. It means that the
value pointed to by the pointer is constant and cannot be changed by the function.
4) I changed the original code so that parameter names were not eg 'szConnStrIn', but 'ptrConnStrIn'. I did that because it appeared 'szConnStrIn' should contain a numeric value for a size. But the sz prefix is widely used in C++ to indicate that it is a null terminated string.
5) If you are a lit graduate like me, be careful, C++ people love metonymy and can confound you by talking about a string and then writing down a pointer. For more information about metonymy and The Container For The Thing Contained, go here:
https://www.newyorker.com/magazine/1942/03/21/here-lies-miss-groby