Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Syntax error

Syntax error

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
17 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P parichaybp

    Hi, can anyone plz tell me what may be the error ??? private: CCreateDlg m_dCreateDlg; // error CStatusDlg m_dStatusDlg; Compiling... UpdateDlg.cpp d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2146: syntax error : missing ';' before identifier 'm_dCreateDlg' d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2501: 'CCreateDlg' : missing storage-class or type specifiers d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2501: 'm_dCreateDlg' : missing storage-class or type specifiers Error executing cl.exe. DesktopSearch.exe - 3 error(s), 0 warning(s)

    L Offline
    L Offline
    Laxman Auti
    wrote on last edited by
    #3

    Have you included the CreateDlg.h in you UpdateDlg.cpp file..?? if not then include it and try to bulid the application CreateDlg.h file having the class definition of CCreateDlg class Knock out "T" from CAN'T You 'CAN' if you think you 'CAN' :cool:

    P 1 Reply Last reply
    0
    • L Laxman Auti

      Have you included the CreateDlg.h in you UpdateDlg.cpp file..?? if not then include it and try to bulid the application CreateDlg.h file having the class definition of CCreateDlg class Knock out "T" from CAN'T You 'CAN' if you think you 'CAN' :cool:

      P Offline
      P Offline
      parichaybp
      wrote on last edited by
      #4

      // UpdateDlg.cpp : implementation file // #include "StatusDlg.h" #include "stdafx.h" #include "DesktopSearch.h" #include "CreateDlg.h" #include "UpdateDlg.h" #include "FoldersDialog.h" I have added CreateDlg.h but still i am getting the same error

      T 1 Reply Last reply
      0
      • P parichaybp

        // UpdateDlg.cpp : implementation file // #include "StatusDlg.h" #include "stdafx.h" #include "DesktopSearch.h" #include "CreateDlg.h" #include "UpdateDlg.h" #include "FoldersDialog.h" I have added CreateDlg.h but still i am getting the same error

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #5

        you didn't read the errors properly : d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) you have to #include "CreateDlg.h" in the UpdateDlg.**h** ! one last thing : move the "stdafx.h" include at the top of all other includes to avoid compilation problems due to the use of precompiled header. -- modified at 8:12 Monday 10th April, 2006

        P 1 Reply Last reply
        0
        • T toxcct

          you forgot to #include the header which contains the definition of the CCreateDlg...

          P Offline
          P Offline
          parichaybp
          wrote on last edited by
          #6

          // UpdateDlg.cpp : implementation file // #include "StatusDlg.h" #include "stdafx.h" #include "DesktopSearch.h" #include "CreateDlg.h" #include "UpdateDlg.h" #include "FoldersDialog.h" I have added CreateDlg.h but still i am getting the same error

          T 1 Reply Last reply
          0
          • P parichaybp

            Hi, can anyone plz tell me what may be the error ??? private: CCreateDlg m_dCreateDlg; // error CStatusDlg m_dStatusDlg; Compiling... UpdateDlg.cpp d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2146: syntax error : missing ';' before identifier 'm_dCreateDlg' d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2501: 'CCreateDlg' : missing storage-class or type specifiers d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2501: 'm_dCreateDlg' : missing storage-class or type specifiers Error executing cl.exe. DesktopSearch.exe - 3 error(s), 0 warning(s)

            E Offline
            E Offline
            eli15021979
            wrote on last edited by
            #7

            Hi , just wondering : Are you sure that your class's name is CCreateDlg and not CreateDlg(when creating a class with 'C' as a first letter - the class wizard , from some reason does not add the prefix 'C' to the claas name...:)). Regards, Eli

            T 1 Reply Last reply
            0
            • P parichaybp

              // UpdateDlg.cpp : implementation file // #include "StatusDlg.h" #include "stdafx.h" #include "DesktopSearch.h" #include "CreateDlg.h" #include "UpdateDlg.h" #include "FoldersDialog.h" I have added CreateDlg.h but still i am getting the same error

              T Offline
              T Offline
              toxcct
              wrote on last edited by
              #8

              read my other answer... you included the headers in the wrong file

              1 Reply Last reply
              0
              • E eli15021979

                Hi , just wondering : Are you sure that your class's name is CCreateDlg and not CreateDlg(when creating a class with 'C' as a first letter - the class wizard , from some reason does not add the prefix 'C' to the claas name...:)). Regards, Eli

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #9

                you're wrong eli. the class wizard removes the leading C to the file names containing the definition and the implementation of the class beeing created, not directly on the class name. moreover, look at the errors returned by the compiler : d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2501: 'CCreateDlg' : missing storage-class or type specifiers yes, the class is effectively CCreateDlg

                E P 2 Replies Last reply
                0
                • T toxcct

                  you didn't read the errors properly : d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) you have to #include "CreateDlg.h" in the UpdateDlg.**h** ! one last thing : move the "stdafx.h" include at the top of all other includes to avoid compilation problems due to the use of precompiled header. -- modified at 8:12 Monday 10th April, 2006

                  P Offline
                  P Offline
                  parichaybp
                  wrote on last edited by
                  #10

                  UpdateDlg.h #include "StatusDlg.h" // Added by ClassView #include "CreateDlg.h" // Added by ClassView #include CreateDlg.h is add in UpdateDlg.h also but still i am getting error -------------------Configuration: DesktopSearch - Win32 Debug-------------------- Compiling... UpdateDlg.cpp d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2146: syntax error : missing ';' before identifier 'm_dCreateDlg' d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2501: 'CCreateDlg' : missing storage-class or type specifiers d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2501: 'm_dCreateDlg' : missing storage-class or type specifiers Error executing cl.exe. DesktopSearch.exe - 3 error(s), 0 warning(s)

                  1 Reply Last reply
                  0
                  • T toxcct

                    you're wrong eli. the class wizard removes the leading C to the file names containing the definition and the implementation of the class beeing created, not directly on the class name. moreover, look at the errors returned by the compiler : d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2501: 'CCreateDlg' : missing storage-class or type specifiers yes, the class is effectively CCreateDlg

                    E Offline
                    E Offline
                    eli15021979
                    wrote on last edited by
                    #11

                    Hi v2.0. You are right:doh: I didn't see that he included the CCreateDlg header file in the Updatedlg implementation file and NOT in the UpdateDlg header file. About the class wizard - for some reason , in my projects , the class wizard removes the leading C from the class name as well. With best regards, Eli

                    1 Reply Last reply
                    0
                    • T toxcct

                      you're wrong eli. the class wizard removes the leading C to the file names containing the definition and the implementation of the class beeing created, not directly on the class name. moreover, look at the errors returned by the compiler : d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2501: 'CCreateDlg' : missing storage-class or type specifiers yes, the class is effectively CCreateDlg

                      P Offline
                      P Offline
                      parichaybp
                      wrote on last edited by
                      #12

                      // UpdateDlg.cpp : implementation file // #include "stdafx.h" #include "DesktopSearch.h" #include "StatusDlg.h" #include "CreateDlg.h" #include "UpdateDlg.h" #include "FoldersDialog.h" ---------------------------------- //UpdateDlg.h file #if !defined(AFX_UPDATEDLG_H__440FE7B3_AA09_4A4C_8F1B_6E86EAE82E27__INCLUDED_) #define AFX_UPDATEDLG_H__440FE7B3_AA09_4A4C_8F1B_6E86EAE82E27__INCLUDED_ #include "StatusDlg.h" // Added by ClassView #include "CreateDlg.h" // Added by ClassView #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // UpdateDlg.h : header file // ---------------------------------------------------- UpdateDlg.h private: CCreateDlg m_dCreateDlg;//error CStatusDlg m_dStatusDlg; ---------------------------------------------- --------------------Configuration: DesktopSearch - Win32 Debug-------------------- Compiling... UpdateDlg.cpp d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2146: syntax error : missing ';' before identifier 'm_dCreateDlg' d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2501: 'CCreateDlg' : missing storage-class or type specifiers d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2501: 'm_dCreateDlg' : missing storage-class or type specifiers Error executing cl.exe. DesktopSearch.exe - 3 error(s), 0 warning(s)

                      E 1 Reply Last reply
                      0
                      • P parichaybp

                        // UpdateDlg.cpp : implementation file // #include "stdafx.h" #include "DesktopSearch.h" #include "StatusDlg.h" #include "CreateDlg.h" #include "UpdateDlg.h" #include "FoldersDialog.h" ---------------------------------- //UpdateDlg.h file #if !defined(AFX_UPDATEDLG_H__440FE7B3_AA09_4A4C_8F1B_6E86EAE82E27__INCLUDED_) #define AFX_UPDATEDLG_H__440FE7B3_AA09_4A4C_8F1B_6E86EAE82E27__INCLUDED_ #include "StatusDlg.h" // Added by ClassView #include "CreateDlg.h" // Added by ClassView #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // UpdateDlg.h : header file // ---------------------------------------------------- UpdateDlg.h private: CCreateDlg m_dCreateDlg;//error CStatusDlg m_dStatusDlg; ---------------------------------------------- --------------------Configuration: DesktopSearch - Win32 Debug-------------------- Compiling... UpdateDlg.cpp d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2146: syntax error : missing ';' before identifier 'm_dCreateDlg' d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2501: 'CCreateDlg' : missing storage-class or type specifiers d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2501: 'm_dCreateDlg' : missing storage-class or type specifiers Error executing cl.exe. DesktopSearch.exe - 3 error(s), 0 warning(s)

                        E Offline
                        E Offline
                        eli15021979
                        wrote on last edited by
                        #13

                        Do you realy have a sub directory called desktopsearch inside the directory with the same name?

                        1 Reply Last reply
                        0
                        • P parichaybp

                          Hi, can anyone plz tell me what may be the error ??? private: CCreateDlg m_dCreateDlg; // error CStatusDlg m_dStatusDlg; Compiling... UpdateDlg.cpp d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2146: syntax error : missing ';' before identifier 'm_dCreateDlg' d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2501: 'CCreateDlg' : missing storage-class or type specifiers d:\parichay\desktopsearch\desktopsearch\updatedlg.h(54) : error C2501: 'm_dCreateDlg' : missing storage-class or type specifiers Error executing cl.exe. DesktopSearch.exe - 3 error(s), 0 warning(s)

                          K Offline
                          K Offline
                          khan
                          wrote on last edited by
                          #14

                          I think the error is because you are cross-including files; I mean including fileA.h in fileB.h and fileB.h in fileA.h etc. You could just declare the class like: class CCreateDlg; Then declare a pointer: CCreateDlg* m_pDlg; etc. this is this.

                          P 2 Replies Last reply
                          0
                          • K khan

                            I think the error is because you are cross-including files; I mean including fileA.h in fileB.h and fileB.h in fileA.h etc. You could just declare the class like: class CCreateDlg; Then declare a pointer: CCreateDlg* m_pDlg; etc. this is this.

                            P Offline
                            P Offline
                            parichaybp
                            wrote on last edited by
                            #15

                            Thank u very much its working.

                            1 Reply Last reply
                            0
                            • K khan

                              I think the error is because you are cross-including files; I mean including fileA.h in fileB.h and fileB.h in fileA.h etc. You could just declare the class like: class CCreateDlg; Then declare a pointer: CCreateDlg* m_pDlg; etc. this is this.

                              P Offline
                              P Offline
                              parichaybp
                              wrote on last edited by
                              #16

                              Hi, i have new button on sigle click i want a dialog window to open i have declared variables as follows.. can anyone help to solve this problem..?? UpdateDlg.h #include "StatusDlg.h" // Added by ClassView #include "CreateDlg.h" // Added by ClassView private: CStatusDlg m_dStatusDlg; class CCreateDlg; //Then declare a pointer: CCreateDlg *m_dCreateDlg; --------------------- // UpdateDlg.cpp : implementation file // #include "stdafx.h" #include "DesktopSearch.h" #include "StatusDlg.h" #include "CreateDlg.h" #include "UpdateDlg.h" #include "FoldersDialog.h" void CUpdateDlg::OnNew() { // TODO: Add your control notification handler code here m_dCreateDlg.DoModal(); } --------------------------------------------------------------- --------------------Configuration: DesktopSearch - Win32 Debug-------------------- Compiling... UpdateDlg.cpp D:\Parichay\DesktopSearch\DesktopSearch\UpdateDlg.cpp(182) : error C2228: left of '.DoModal' must have class/struct/union type Error executing cl.exe. DesktopSearch.exe - 1 error(s), 0 warning(s)

                              K 1 Reply Last reply
                              0
                              • P parichaybp

                                Hi, i have new button on sigle click i want a dialog window to open i have declared variables as follows.. can anyone help to solve this problem..?? UpdateDlg.h #include "StatusDlg.h" // Added by ClassView #include "CreateDlg.h" // Added by ClassView private: CStatusDlg m_dStatusDlg; class CCreateDlg; //Then declare a pointer: CCreateDlg *m_dCreateDlg; --------------------- // UpdateDlg.cpp : implementation file // #include "stdafx.h" #include "DesktopSearch.h" #include "StatusDlg.h" #include "CreateDlg.h" #include "UpdateDlg.h" #include "FoldersDialog.h" void CUpdateDlg::OnNew() { // TODO: Add your control notification handler code here m_dCreateDlg.DoModal(); } --------------------------------------------------------------- --------------------Configuration: DesktopSearch - Win32 Debug-------------------- Compiling... UpdateDlg.cpp D:\Parichay\DesktopSearch\DesktopSearch\UpdateDlg.cpp(182) : error C2228: left of '.DoModal' must have class/struct/union type Error executing cl.exe. DesktopSearch.exe - 1 error(s), 0 warning(s)

                                K Offline
                                K Offline
                                khan
                                wrote on last edited by
                                #17

                                I don't think you are very familiar with pointers and their uses. Using the pointer to declare the variable would mean that you have to give it memory by using the new operator. Then create the dialog using Create(...) then show the dialog using ShowWindow(...). This could be the code: class CCreateDlg; //Then declare a pointer: CCreateDlg *m_dCreateDlg; Now on button-click: m_dCreateDlg = new CCreateDlg(); m_dCreateDlg->Create(IDD_WHATEVER);//use the ID your dialog template uses here. m_dCreateDlg->ShowWindow(SW_SHOW); This would create a modeless dialog. Note that this would give memory leaks if you do not dispose if off correctly. And if you want to re-use the pointer to create the dialog again, there could be problems. Another way would be: m_dCreateDlg = new CCreateDlg; m_dCreateDlg->DoModal(); this is this.

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups