Compilation problem....

I am getting the following compile error:

C:\Working\jnli\ocx\Jnli_ocxCtl.cpp(284) : error C2664: 'NLGetVariable' : cannot convert parameter 1 from 'class CString' to 'unsigned short ** '
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

The offending code is:

BSTR CJnli_ocxCtrl::NLGetVariable(BSTR FAR* variableName)
      CString variable = *variableName;
      CString foo = NLGetVariable(variable);
      return foo.AllocSysString();

And the problem pointer points to line "CSTring foo = NLGetVariable(variable);"

The NLGetVariable to the right of the “=” in that line is pointing to an included dll, and the function in that dll is defined as:

const char* NLGetVariable(const char* variableName)
      _bstr_t result = parsers[0]->getVariable(_bstr_t(variableName));
      const char* buff = (const char*) result;
      return stringCopy(buff);

Any quick ideas?
Who is Participating?
applebyConnect With a Mentor Commented:
Use the CString::GetBuffer() method to access the character buffer of the CString variable.  Modify your line that says
    CString foo = NLGetVariable(variable);

so that it instead says
    CString foo = NLGetVariable(variable->GetBuffer());

You should be able to pass this into NLGetVariable in this way, if it gives you trouble you can define a const char* and set it equal to variable->GetBuffer() and then pass the const char* in.

Hope it helps.
All Courses

From novice to tech pro — start learning today.