error C2143: syntax error : missing ';' before '.'
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: error C2143: syntax error : missing ';' before '.'

  1. #1
    Join Date
    Jun 2008
    Posts
    3

    error C2143: syntax error : missing ';' before '.'

    Hello Friends,

    Here in this file i found this error but could not solve it. the line is highlighted with red color in the program. So please help me to solve it.

    motoDlg.cpp(224) : error C2143: syntax error : missing ';' before '.'
    motoDlg.cpp(224) : error C2143: syntax error : missing ';' before '.'

    Code:
    // motoDlg.cpp : implementation file
    //
    
    #include "stdafx.h"
    #include "moto.h"
    #include "Sock.h"
    #include "motoDlg.h"
    #include "MotoCom.h"
    #include <direct.h>
    #include "stdlib.h"
    
    
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif
    
    
    //--------------------------------------------------------------------------
    CMotoDlg *global_dialog;
    //--------------------------------------------------------------------------
    
    
    /////////////////////////////////////////////////////////////////////////////
    // CAboutDlg dialog used for App About
    
    class CAboutDlg : public CDialog
    {
    public:
        CAboutDlg();
    
    // Dialog Data
        //{{AFX_DATA(CAboutDlg)
        enum { IDD = IDD_ABOUTBOX };
        //}}AFX_DATA
    
        // ClassWizard generated virtual function overrides
        //{{AFX_VIRTUAL(CAboutDlg)
        protected:
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
        //}}AFX_VIRTUAL
    
    // Implementation
    protected:
        //{{AFX_MSG(CAboutDlg)
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
    };
    
    CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
    {
        //{{AFX_DATA_INIT(CAboutDlg)
        //}}AFX_DATA_INIT
    }
    
    void CAboutDlg::DoDataExchange(CDataExchange* pDX)
    {
        CDialog::DoDataExchange(pDX);
        //{{AFX_DATA_MAP(CAboutDlg)
        //}}AFX_DATA_MAP
    }
    
    BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
        //{{AFX_MSG_MAP(CAboutDlg)
            // No message handlers
        //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    
    /////////////////////////////////////////////////////////////////////////////
    // CMotoDlg dialog
    
    CMotoDlg::CMotoDlg(CWnd* pParent /*=NULL*/)
        : CDialog(CMotoDlg::IDD, pParent)
    {
        //{{AFX_DATA_INIT(CMotoDlg)
        m_strMsg = _T("");
    //    m_ip = _T("");
    //    m_port = 0;
        //}}AFX_DATA_INIT
        // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
        m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
    
    //----------------------------------------------------------------------------
        global_dialog = this;
    //----------------------------------------------------------------------------
    
    }
    
    void CMotoDlg::DoDataExchange(CDataExchange* pDX)
    {
        CDialog::DoDataExchange(pDX);
        //{{AFX_DATA_MAP(CMotoDlg)
        DDX_Control(pDX, IDC_LSENT, m_ctlSent);
        DDX_Control(pDX, IDC_LRECEIVED, m_ctlRcvd);
        DDX_Control(pDX, IDC_BCONNECT, m_ctlConnect);
        DDX_Text(pDX, IDC_EMSG, m_strMsg);
    //    DDX_Text(pDX, IDC_EDITIP, m_ip);
    //    DDX_Text(pDX, IDC_EDITPORT, m_port);
        //}}AFX_DATA_MAP
    }
    
    BEGIN_MESSAGE_MAP(CMotoDlg, CDialog)
        //{{AFX_MSG_MAP(CMotoDlg)
        ON_WM_SYSCOMMAND()
        ON_WM_PAINT()
        ON_WM_QUERYDRAGICON()
        ON_BN_CLICKED(IDC_BCONNECT, OnBconnect)
        ON_BN_CLICKED(IDC_BSEND, OnBsend)
        ON_BN_CLICKED(IDC_BCLOSE, OnBclose)
        //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    
    /////////////////////////////////////////////////////////////////////////////
    // CMotoDlg message handlers
    
    BOOL CMotoDlg::OnInitDialog()
    {
        CDialog::OnInitDialog();
    
        // Add "About..." menu item to system menu.
    
        // IDM_ABOUTBOX must be in the system command range.
        ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
        ASSERT(IDM_ABOUTBOX < 0xF000);
    
        CMenu* pSysMenu = GetSystemMenu(FALSE);
        if (pSysMenu != NULL)
        {
            CString strAboutMenu;
            strAboutMenu.LoadString(IDS_ABOUTBOX);
            if (!strAboutMenu.IsEmpty())
            {
                pSysMenu->AppendMenu(MF_SEPARATOR);
                pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
            }
        }
    
        // Set the icon for this dialog.  The framework does this automatically
        //  when the application's main window is not a dialog
        SetIcon(m_hIcon, TRUE);            // Set big icon
        SetIcon(m_hIcon, FALSE);        // Set small icon
       
        // TODO: Add extra initialization here
    
        //Initialize the control variables
    //    m_ip = "149.201.4.66";
    //    m_port = 4000;
    
        //Update the Controls
        UpdateData(FALSE);
    
        // Set the dialog pointers
        m_sConnectSocket.SetParent(this);
        m_sListenSocket.SetParent(this);
    
        return TRUE;  // return TRUE  unless you set the focus to a control
    }
    
    void CMotoDlg::OnSysCommand(UINT nID, LPARAM lParam)
    {
        if ((nID & 0xFFF0) == IDM_ABOUTBOX)
        {
            CAboutDlg dlgAbout;
            dlgAbout.DoModal();
        }
        else
        {
            CDialog::OnSysCommand(nID, lParam);
        }
    }
    
    // If you add a minimize button to your dialog, you will need the code below
    //  to draw the icon.  For MFC applications using the document/view model,
    //  this is automatically done for you by the framework.
    
    void CMotoDlg::OnPaint()
    {
        if (IsIconic())
        {
            CPaintDC dc(this); // device context for painting
    
            SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
    
            // Center icon in client rectangle
            int cxIcon = GetSystemMetrics(SM_CXICON);
            int cyIcon = GetSystemMetrics(SM_CYICON);
            CRect rect;
            GetClientRect(&rect);
            int x = (rect.Width() - cxIcon + 1) / 2;
            int y = (rect.Height() - cyIcon + 1) / 2;
    
            // Draw the icon
            dc.DrawIcon(x, y, m_hIcon);
        }
        else
        {
            CDialog::OnPaint();
        }
    }
    
    // The system calls this to obtain the cursor to display while the user drags
    //  the minimized window.
    HCURSOR CMotoDlg::OnQueryDragIcon()
    {
        return (HCURSOR) m_hIcon;
    }
    
    
    void CMotoDlg::OnBconnect()
    {
        // TODO: Add your control notification handler code here
       
        UpdateData(TRUE);
    
        // Client, create default socket
    //    m_sConnectSocket.Create();
        // Open connection to the server
    //    m_sConnectSocket.Connect(m_ip, m_port);
       
    //    char IP[20] = "149.201.4.66";
    
        // Function of CMOTOCOM32 class
        CMOTOCOM32.ConnectToXRC("149.201.4.66");
    
        // Disable the connection and type controls
        GetDlgItem(IDC_BCONNECT)->EnableWindow(FALSE);
        GetDlgItem(IDC_EDITIP)->EnableWindow(FALSE);
        GetDlgItem(IDC_EDITPORT)->EnableWindow(FALSE);
    
        OnConnect();
    
    
        // Run Hslsrv.exe
        system("Hslsrv.exe");
    
    }
    FYI: class CMOTOCOM32 is declared into the motoDlg.h file.

    Please give your comments and suggestions.

    Thank you
    Last edited by cilu; September 19th, 2008 at 01:59 AM. Reason: code tags

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,301

    Re: error C2143: syntax error : missing ';' before '.'

    1. Please, edit your post to add Code tags around code snippet. Otherwise it is hard to read/understand the code.
    2. Where is the line 224?
    3. I don't see any sense to declare this variable as global:
    Quote Originally Posted by kelisana
    Code:
    CMotoDlg *global_dialog;
    Victor Nijegorodov

  3. #3
    Join Date
    Mar 2008
    Posts
    67

    Re: error C2143: syntax error : missing ';' before '.'

    I thnk without creating an object for the CMOTOCOM32 class you cannot call the function ConnectToXRC("149.201.4.66"); like that.If the function is a static function then u can use scope resolution operator and use without creating an object.So create an object for the class and then using the object call the function.......

  4. #4
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: error C2143: syntax error : missing ';' before '.'

    Code:
    // Function of CMOTOCOM32 class
    CMOTOCOM32.ConnectToXRC("149.201.4.66");
    Is CMOTOCOM32 a class or an object? If the later, how is it declared? If the former, then you need an object of that type to call the functions. Unless that function is static, in which case you need to call it like this:
    Code:
    CMOTOCOM32::ConnectToXRC("149.201.4.66");
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center