【问题标题】:error C2065: undeclared identifier错误 C2065:未声明的标识符
【发布时间】:2011-02-15 07:35:00
【问题描述】:

目前,我的其他 cpp 文件中有此功能:

  UINT32 functionHtml(const wchar_t *url)
  {
     WinHttpClient client(url);
     client.SendHttpRequest();
     wstring httpResponseHeader = client.GetHttpResponseHeader();
     wstring httpResponse = client.GetHttpResponse();     
     writeToLog(httpResponse.c_str());

     return 0;
  }

我有另一个 cpp 文件,我想执行上述文件中的内容。这是另一个文件的代码:

HRESULT CButtonDemoBHO::onDocumentComplete(IDispatch *pDisp, VARIANT *vUrl){
ATLTRACE("CButtonDemoBHO::onDocumentComplete %S\n", vUrl->bstrVal);

//  <---- i would like to call funtionHTML here or ..

if (isMainFrame(pDisp)){
    m_normalPageLoad=false;

//  <---- here..

  MessageBox(m_hWnd, L"Main Document has completed loading", L"Document Complete", MB_OK);

  return S_OK;
 }
 return S_OK;

}

我收到错误 C2065: 'url' : undeclared identifier。 需要帮助。

【问题讨论】:

    标签: c++ visual-studio


    【解决方案1】:

    您需要将 vUrl 从 VARIANT*(不熟悉该类型)转换为 const wchar_t* 类型的对象,并在该结果对象上调用 functionHtml。您收到“未声明的标识符”错误的原因是您尝试调用functionHtml(url),尽管在您尝试进行该调用的范围内没有名为url 的变量;您需要创建自己的 const wchar_t* 类型的变量以用作 functionHtml() 的参数。

    【讨论】:

      猜你喜欢
      • 2011-04-16
      • 2011-04-16
      • 2010-12-24
      • 2023-03-04
      • 2011-03-02
      • 2011-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多