error C2065: “servAddr”: 未声明的标识符__错误记录

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u013636149/article/details/72123301
当报警error C2065;1.查看头文件,都有  ;2.看头文件排列顺序  ,无问题;3.servAddr没掌握清楚,sockaddr结构体 或者  sockaddr_in 结构体都需要声明,如SOCKADDR_IN servAddr;声明后无问题
展开阅读全文

error C2065: “m_pStrategyDlg”: 未声明标识符

10-28

新手请教个问题,网上查了半天也没找到原因。rnTESTStrategy.h里定义一个对话框的(TestItpDialog* m_pStrategyDlg;),但在TESTStrategy.cpp里面Strategy_CreatWindow函数使用该变量时总是提示“error C2065: “m_pStrategyDlg”: 未声明的标识符”。rnTESTSTRATEGY.H代码:rn#pragma oncern#include "strategybase.h"rn#include "list"rn#include rn#include "map"rn#include "TestItpDialog.h"//TestItpDialog 类的头文件rnrnusing std::vector;rnusing std::list;rnusing std::map;rnrnconst int MAX_BAR_SIZE = 1000;rnrnclass TestStrategy :rnpublic CStrategyBasernrnpublic:rnTestStrategy(void);rn~TestStrategy(void);rnrnvirtual int Strategy_OnStart(IiTPInterface* piTP);rnvirtual int Strategy_OnStop(IiTPInterface* piTP);rnvirtual int Strategy_CreatWindow(HWND hWnd,HWND hWndParent);rnvirtual int Strategy_DestroyWindow(HWND hWnd);rnrnprivate:rnrnTestItpDialog* m_pStrategyDlg; // 策略窗口rnrn;rnrnTESTStrategy.cpp里rnint Strategy_CreatWindow(HWND hWnd,HWND hWndParent)rnrn// 创建策略窗口rnAFX_MANAGE_STATE(AfxGetStaticModuleState());rnm_pStrategyDlg = new TestTipDialog;rnif (NULL == m_pStrategyDlg)rnrnASSERT(FALSE);rnreturn -1;rnrnif (!::IsWindow(m_pStrategyDlg->GetSafeHwnd()) && !m_pStrategyDlg->Create(TestItpDialog::IDD))rn rn return -1;rn rnm_pStrategyDlg->ModifyStyleEx(WS_POPUP | WS_BORDER | WS_DLGFRAME,WS_CHILD);rn hWnd = m_pStrategyDlg->GetSafeHwnd();rnreturn 0;rnrnrn 论坛

error C2065: “_ConnectionPtr”: 未声明标识符

01-16

莫名其妙啊,以前从来没遇到这问题,今天终于碰到了,大家看看我哪里出问题了rn1、在stdafx.h 最后包含rn[code=c]rn#import "c:\program files\common files\system\ado\msado15.dll" named_guids rename_namespace("ADOCG") rename("EOF", "adoEOF") rename("BOF","adoBOF")rnusing namespace ADOCGrn[/code]rn2、然后我自定义了一个类函数rn[code=c]rnvoid CIOCPModel::WriteIntoDataBase(CString str1, CString str2)rn//str1、str2是传进来的字符串rnrn CoInitialize(NULL);rn _ConnectionPtr m_pConnection; //连接对象指针rn tryrn rn m_pConnection.CreateInstance("ADODB.Connection"); //创建连接对象实例rn bstr_t strConnect="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Modbus_TCP.mdb;Persist Security Info=False";rn m_pConnection->Open(strConnect,"","",adModeUnknown); //打开数据库rn rn catch (_com_error e) //捕捉错误rn rn AfxMessageBox(e.Description()); rn return;//弹出错误rn rn tryrn rn _bstr_t sql = _T("INSERT INTO message (时间,内容) VALUES (str1,str2)");rn m_pConnection->Execute(sql,NULL,adCmdText);rn rn catch (_com_error e)rn rn AfxMessageBox(e.Description()); rn return;//弹出错误rn rnrn m_pConnection->Close();rn CoUninitialize();rnrn[/code]rn3、结果就悲剧了,大家帮我看看是漏了什么还是。。。rn[code=text]rn错误信息rn错误 7 error C2065: “_ConnectionPtr”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 814 PiggyIOCPServerrn错误 8 error C2146: 语法错误 : 缺少“;”(在标识符“m_pConnection”的前面) c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 814 PiggyIOCPServerrn错误 9 error C2065: “m_pConnection”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 814 PiggyIOCPServerrn错误 10 error C2065: “m_pConnection”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 817 PiggyIOCPServerrn错误 11 error C2228: “.CreateInstance”的左边必须有类/结构/联合 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 817 PiggyIOCPServerrn错误 12 error C2065: “bstr_t”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 818 PiggyIOCPServerrn错误 13 error C2146: 语法错误 : 缺少“;”(在标识符“strConnect”的前面) c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 818 PiggyIOCPServerrn错误 14 error C2065: “strConnect”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 818 PiggyIOCPServerrn错误 15 error C2065: “m_pConnection”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 819 PiggyIOCPServerrn错误 16 error C2227: “->Open”的左边必须指向类/结构/联合/泛型类型 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 819 PiggyIOCPServerrn错误 17 error C2065: “strConnect”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 819 PiggyIOCPServerrn错误 18 error C2065: “adModeUnknown”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 819 PiggyIOCPServerrn错误 19 error C2061: 语法错误 : 标识符“_com_error” c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 821 PiggyIOCPServerrn错误 20 error C2310: catch 处理程序必须指定一种类型 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 821 PiggyIOCPServerrn错误 21 error C2065: “e”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 823 PiggyIOCPServerrn错误 22 error C2228: “.Description”的左边必须有类/结构/联合 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 823 PiggyIOCPServerrn错误 23 error C2317: 在行“816”上开始的“try”块没有 catch 处理程序 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 826 PiggyIOCPServerrn错误 24 error C2065: “_bstr_t”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 828 PiggyIOCPServerrn错误 25 error C2146: 语法错误 : 缺少“;”(在标识符“sql”的前面) c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 828 PiggyIOCPServerrn错误 26 error C2065: “sql”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 828 PiggyIOCPServerrn错误 27 error C2065: “m_pConnection”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 829 PiggyIOCPServerrn错误 28 error C2227: “->Execute”的左边必须指向类/结构/联合/泛型类型 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 829 PiggyIOCPServerrn错误 29 error C2065: “sql”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 829 PiggyIOCPServerrn错误 30 error C2065: “adCmdText”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 829 PiggyIOCPServerrn错误 31 error C2061: 语法错误 : 标识符“_com_error” c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 831 PiggyIOCPServerrn错误 32 error C2310: catch 处理程序必须指定一种类型 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 831 PiggyIOCPServerrn错误 33 error C2065: “e”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 833 PiggyIOCPServerrn错误 34 error C2228: “.Description”的左边必须有类/结构/联合 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 833 PiggyIOCPServerrn错误 35 error C2317: 在行“827”上开始的“try”块没有 catch 处理程序 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 837 PiggyIOCPServerrn错误 36 error C2065: “m_pConnection”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 837 PiggyIOCPServerrn错误 37 error C2227: “->Close”的左边必须指向类/结构/联合/泛型类型 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 837 PiggyIOCPServerrnrn[/code] 论坛

error C2065: “crFore”: 未声明标识符

06-07

// fuxuandanxuanDlg.cpp : 实现文件rn//rnrn#include "stdafx.h"rn#include "fuxuandanxuan.h"rn#include "fuxuandanxuanDlg.h"rnrn#ifdef _DEBUGrn#define new DEBUG_NEWrn#endifrnrnrn// 用于应用程序“关于”菜单项的 CAboutDlg 对话框rnrnclass CAboutDlg : public CDialogrnrnpublic:rn CAboutDlg();rnrn// 对话框数据rn enum IDD = IDD_ABOUTBOX ;rnrn protected:rn virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持rnrn// 实现rnprotected:rn DECLARE_MESSAGE_MAP()rn;rnrnCAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)rnrnrnrnvoid CAboutDlg::DoDataExchange(CDataExchange* pDX)rnrn CDialog::DoDataExchange(pDX);rnrnrnBEGIN_MESSAGE_MAP(CAboutDlg, CDialog)rnEND_MESSAGE_MAP()rnrnrn// CfuxuandanxuanDlg 对话框rnrnrnrnrnCfuxuandanxuanDlg::CfuxuandanxuanDlg(CWnd* pParent /*=NULL*/)rn : CDialog(CfuxuandanxuanDlg::IDD, pParent)rnrn m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);rnrnrnvoid CfuxuandanxuanDlg::DoDataExchange(CDataExchange* pDX)rnrn CDialog::DoDataExchange(pDX);rn DDX_Control(pDX, IDC_CHK_BLUE, m_chk_blue);rn DDX_Control(pDX, IDC_CHK_GREEN, m_chk_green);rn DDX_Control(pDX, IDC_CHK_RED, m_chk_red);rn DDX_Control(pDX, IDC_RD_RECT, m_rd_rect);rn DDX_Control(pDX, IDC_RD_ROUND, m_rd_round);rnrnrnBEGIN_MESSAGE_MAP(CfuxuandanxuanDlg, CDialog)rn ON_WM_SYSCOMMAND()rn ON_WM_PAINT()rn ON_WM_QUERYDRAGICON()rn //AFX_MSG_MAPrn ON_WM_ERASEBKGND()rn ON_BN_CLICKED(IDC_CHK_BLUE, &CfuxuandanxuanDlg::OnBnClickedChkBlue)rn ON_BN_CLICKED(IDC_CHK_GREEN, &CfuxuandanxuanDlg::OnBnClickedChkGreen)rn ON_BN_CLICKED(IDC_CHK_RED, &CfuxuandanxuanDlg::OnBnClickedChkRed)rn ON_BN_CLICKED(IDC_RD_RECT, &CfuxuandanxuanDlg::OnBnClickedRdRect)rn ON_BN_CLICKED(IDC_RD_ROUND, &CfuxuandanxuanDlg::OnBnClickedRdRound)rnEND_MESSAGE_MAP()rnrnrn// CfuxuandanxuanDlg 消息处理程序rnrnBOOL CfuxuandanxuanDlg::OnInitDialog()rnrn CDialog::OnInitDialog();rnrn // 将“关于...”菜单项添加到系统菜单中。rnrn // IDM_ABOUTBOX 必须在系统命令范围内。rn ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);rn ASSERT(IDM_ABOUTBOX < 0xF000);rnrn CMenu* pSysMenu = GetSystemMenu(FALSE);rn if (pSysMenu != NULL)rn rn CString strAboutMenu;rn strAboutMenu.LoadString(IDS_ABOUTBOX);rn if (!strAboutMenu.IsEmpty())rn rn pSysMenu->AppendMenu(MF_SEPARATOR);rn pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);rn rn rn CheckRadioButton(IDC_RD_RECT,IDC_RD_ROUND,IDC_RD_ROUND);rnrnrn // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动rn // 执行此操作rn SetIcon(m_hIcon, TRUE); // 设置大图标rn SetIcon(m_hIcon, FALSE); // 设置小图标rnrn // TODO: 在此添加额外的初始化代码rnrn return TRUE; // 除非将焦点设置到控件,否则返回 TRUErnrnrnvoid CfuxuandanxuanDlg::OnSysCommand(UINT nID, LPARAM lParam)rnrn if ((nID & 0xFFF0) == IDM_ABOUTBOX)rn rn CAboutDlg dlgAbout;rn dlgAbout.DoModal();rn rn elsern rn CDialog::OnSysCommand(nID, lParam);rn rnrnrn// 如果向对话框添加最小化按钮,则需要下面的代码rn// 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,rn// 这将由框架自动完成。rnrnvoid CfuxuandanxuanDlg::OnPaint()rnrn if (IsIconic())rn rn CPaintDC dc(this); // 用于绘制的设备上下文rnrn SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0);rnrn // 使图标在工作区矩形中居中rn int cxIcon = GetSystemMetrics(SM_CXICON);rn int cyIcon = GetSystemMetrics(SM_CYICON);rn CRect rect;rn GetClientRect(&rect);rn int x = (rect.Width() - cxIcon + 1) / 2;rn int y = (rect.Height() - cyIcon + 1) / 2;rnrn // 绘制图标rn dc.DrawIcon(x, y, m_hIcon);rn rn elsern rn CDialog::OnPaint();rn rnrnrn//当用户拖动最小化窗口时系统调用此函数取得光标rn//显示。rnHCURSOR CfuxuandanxuanDlg::OnQueryDragIcon()rnrn return static_cast(m_hIcon);rnrnrnrnBOOL CfuxuandanxuanDlg::OnEraseBkgnd(CDC* pDC)rnrn //先绘制默认背景rn BOOL bRet=CDialog::OnEraseBkgnd(pDC);rn //获取复选框控件所选的颜色rn int nRed,nGreen,nBlue;rn rn nRed=m_chk_red.GetCheck()?255:0;rn nGreen=m_chk_green.GetCheck()?255:0;rn nBlue=m_chk_blue.GetCheck()?255:0;rn//根据选择组成颜色rn COLORREF crFrore=RGB(nRed,nGreen,nBlue);rn //创建制定颜色的画刷rn CBrush brush;rn brush.CreateSolidBrush(crFore);rn //将画刷入DCrn CBrush *pOldBrush = pDC->SelectObject(&brush);rn //根据选择,绘制矩形或圆形rn RECT rc =50,20,150,120;rn if (m_rd_rect.GetCheck())rn pDC->Rectangle(&rc);rn elsern pDC->Ellipse(&rc);rn //恢复DC原状rn pDC->SelectObject(pOldBrush);rnrn return bRet;rnrnrnvoid CfuxuandanxuanDlg::OnBnClickedChkBlue()rnrn rnInvalidate();rnrnrnvoid CfuxuandanxuanDlg::OnBnClickedChkGreen()rnrn OnBnClickedChkBlue();rnrnrnvoid CfuxuandanxuanDlg::OnBnClickedChkRed()rnrn OnBnClickedChkBlue();rnrnrnvoid CfuxuandanxuanDlg::OnBnClickedRdRect()rnrn OnBnClickedChkBlue();rnrnrnvoid CfuxuandanxuanDlg::OnBnClickedRdRound()rnrn OnBnClickedChkBlue();rnrn运行了出现如题的错误。 rn请教高手。。 论坛

没有更多推荐了,返回首页