trying to include CView file 
Author Message
 trying to include CView file

My CView file is Room 101View.h.  When I try to include it
in a .cpp file, I get these errors:

Compiling...
Planner.cpp
c:\hand in hand\room 101\room 101view.h(24) : error C2143:
syntax error : missing ';' before '*'
c:\hand in hand\room 101\room 101view.h(24) : error
C2501: 'CRoom101Doc' : missing storage-class or type
specifiers
c:\hand in hand\room 101\room 101view.h(24) : error
C2501: 'GetDocument' : missing storage-class or type
specifiers
Error executing cl.exe.

Can I get an explanation?  Thanks!



Sun, 11 Sep 2005 01:51:57 GMT  
 trying to include CView file
What does your include file look like?

--
Ajay Kalra [MVP - VC++]


Quote:
> My CView file is Room 101View.h.  When I try to include it
> in a .cpp file, I get these errors:

> Compiling...
> Planner.cpp
> c:\hand in hand\room 101\room 101view.h(24) : error C2143:
> syntax error : missing ';' before '*'
> c:\hand in hand\room 101\room 101view.h(24) : error
> C2501: 'CRoom101Doc' : missing storage-class or type
> specifiers
> c:\hand in hand\room 101\room 101view.h(24) : error
> C2501: 'GetDocument' : missing storage-class or type
> specifiers
> Error executing cl.exe.

> Can I get an explanation?  Thanks!



Sun, 11 Sep 2005 07:42:06 GMT  
 trying to include CView file
It's pretty much the standard view header file produced by
AppWizard.  I have added only a few lines to it.
Quote:
>-----Original Message-----
>What does your include file look like?

>--
>Ajay Kalra [MVP - VC++]



>> My CView file is Room 101View.h.  When I try to include
it
>> in a .cpp file, I get these errors:

>> Compiling...
>> Planner.cpp
>> c:\hand in hand\room 101\room 101view.h(24) : error
C2143:
>> syntax error : missing ';' before '*'
>> c:\hand in hand\room 101\room 101view.h(24) : error
>> C2501: 'CRoom101Doc' : missing storage-class or type
>> specifiers
>> c:\hand in hand\room 101\room 101view.h(24) : error
>> C2501: 'GetDocument' : missing storage-class or type
>> specifiers
>> Error executing cl.exe.

>> Can I get an explanation?  Thanks!

>.



Sun, 11 Sep 2005 13:12:00 GMT  
 trying to include CView file

Quote:

> It's pretty much the standard view header file produced by
> AppWizard.  I have added only a few lines to it.

>>-----Original Message-----
>>What does your include file look like?

>>--
>>Ajay Kalra [MVP - VC++]


Hi Steve,

maybe you should try to post your .h file (or at least the first 25
lines of it) if you really need help.

bye,
--
Stadler Erwin
Software Developer
CenterPoint - Connective Software Engineering GmbH
www.cpointc.com



Sun, 11 Sep 2005 13:55:45 GMT  
 trying to include CView file
Obviously you must have changed something in that header file or one of the
files included by the view header file. You should post it.

--
Ajay Kalra [MVP - VC++]


Quote:
> It's pretty much the standard view header file produced by
> AppWizard.  I have added only a few lines to it.
> >-----Original Message-----
> >What does your include file look like?

> >--
> >Ajay Kalra [MVP - VC++]



> >> My CView file is Room 101View.h.  When I try to include
> it
> >> in a .cpp file, I get these errors:

> >> Compiling...
> >> Planner.cpp
> >> c:\hand in hand\room 101\room 101view.h(24) : error
> C2143:
> >> syntax error : missing ';' before '*'
> >> c:\hand in hand\room 101\room 101view.h(24) : error
> >> C2501: 'CRoom101Doc' : missing storage-class or type
> >> specifiers
> >> c:\hand in hand\room 101\room 101view.h(24) : error
> >> C2501: 'GetDocument' : missing storage-class or type
> >> specifiers
> >> Error executing cl.exe.

> >> Can I get an explanation?  Thanks!

> >.



Sun, 11 Sep 2005 19:33:01 GMT  
 trying to include CView file
Okay, below is my header file that seems to be{*filter*} me
up.  When I comment out #include "Room 101View.h" in the
one particular cpp file, the program compiles.  Thanks.

// Room 101View.h : interface of the CRoom101View class
//
///////////////////////////////////////////////////////////
//////////////////

#if !defined
(AFX_ROOM101VIEW_H__37FC4294_AE13_4BBE_9C13_3EA19E0F97CB__I
NCLUDED_)
#define
AFX_ROOM101VIEW_H__37FC4294_AE13_4BBE_9C13_3EA19E0F97CB__IN
CLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CPlanner;

//#define WM_ACTIVITY           WM_USER + 5

class CRoom101View : public CView
{
protected: // create from serialization only
        CRoom101View();
        DECLARE_DYNCREATE(CRoom101View)

// Attributes
public:
        CRoom101Doc* GetDocument();

// Operations
public:

// Overrides
        // ClassWizard generated virtual function overrides
        //{{AFX_VIRTUAL(CRoom101View)
        public:
        virtual void OnDraw(CDC* pDC);  // overridden to
draw this view
        virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
        virtual void OnInitialUpdate();
        protected:
        virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
        virtual void OnBeginPrinting(CDC* pDC, CPrintInfo*
pInfo);
        virtual void OnEndPrinting(CDC* pDC, CPrintInfo*
pInfo);
        //}}AFX_VIRTUAL

// Implementation
public:
        CPlanner* planner;
        void OnActivity(UINT wParam, LONG lParam);
        virtual ~CRoom101View();

#ifdef _DEBUG
        virtual void AssertValid() const;
        virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
        //{{AFX_MSG(CRoom101View)
                // NOTE - the ClassWizard will add and
remove member functions here.
                //    DO NOT EDIT what you see in these
blocks of generated code !
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()

Quote:
};

#ifndef _DEBUG  // debug version in Room 101View.cpp
inline CRoom101Doc* CRoom101View::GetDocument()
   { return (CRoom101Doc*)m_pDocument; }
#endif

///////////////////////////////////////////////////////////
//////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional
declarations immediately before the previous line.

#endif // !defined
(AFX_ROOM101VIEW_H__37FC4294_AE13_4BBE_9C13_3EA19E0F97CB__I
NCLUDED_)

Quote:
>-----Original Message-----
>Obviously you must have changed something in that header
file or one of the
>files included by the view header file. You should post
it.

>--
>Ajay Kalra [MVP - VC++]



>> It's pretty much the standard view header file produced
by
>> AppWizard.  I have added only a few lines to it.
>> >-----Original Message-----
>> >What does your include file look like?

>> >--
>> >Ajay Kalra [MVP - VC++]


message

>> >> My CView file is Room 101View.h.  When I try to
include
>> it
>> >> in a .cpp file, I get these errors:

>> >> Compiling...
>> >> Planner.cpp
>> >> c:\hand in hand\room 101\room 101view.h(24) : error
>> C2143:
>> >> syntax error : missing ';' before '*'
>> >> c:\hand in hand\room 101\room 101view.h(24) : error
>> >> C2501: 'CRoom101Doc' : missing storage-class or type
>> >> specifiers
>> >> c:\hand in hand\room 101\room 101view.h(24) : error
>> >> C2501: 'GetDocument' : missing storage-class or type
>> >> specifiers
>> >> Error executing cl.exe.

>> >> Can I get an explanation?  Thanks!

>> >.

>.



Sun, 11 Sep 2005 22:33:26 GMT  
 trying to include CView file
Try replacing the following

class CPlanner;

with

class CPlanner;
class CRoom101Doc;

--
Ajay Kalra [MVP - VC++]


Quote:
> Okay, below is my header file that seems to be{*filter*} me
> up.  When I comment out #include "Room 101View.h" in the
> one particular cpp file, the program compiles.  Thanks.

> // Room 101View.h : interface of the CRoom101View class
> //
> ///////////////////////////////////////////////////////////
> //////////////////

> #if !defined
> (AFX_ROOM101VIEW_H__37FC4294_AE13_4BBE_9C13_3EA19E0F97CB__I
> NCLUDED_)
> #define
> AFX_ROOM101VIEW_H__37FC4294_AE13_4BBE_9C13_3EA19E0F97CB__IN
> CLUDED_

> #if _MSC_VER > 1000
> #pragma once
> #endif // _MSC_VER > 1000

> class CPlanner;

> //#define WM_ACTIVITY WM_USER + 5

> class CRoom101View : public CView
> {
> protected: // create from serialization only
> CRoom101View();
> DECLARE_DYNCREATE(CRoom101View)

> // Attributes
> public:
> CRoom101Doc* GetDocument();

> // Operations
> public:

> // Overrides
> // ClassWizard generated virtual function overrides
> //{{AFX_VIRTUAL(CRoom101View)
> public:
> virtual void OnDraw(CDC* pDC);  // overridden to
> draw this view
> virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
> virtual void OnInitialUpdate();
> protected:
> virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
> virtual void OnBeginPrinting(CDC* pDC, CPrintInfo*
> pInfo);
> virtual void OnEndPrinting(CDC* pDC, CPrintInfo*
> pInfo);
> //}}AFX_VIRTUAL

> // Implementation
> public:
> CPlanner* planner;
> void OnActivity(UINT wParam, LONG lParam);
> virtual ~CRoom101View();

> #ifdef _DEBUG
> virtual void AssertValid() const;
> virtual void Dump(CDumpContext& dc) const;
> #endif

> protected:

> // Generated message map functions
> protected:
> //{{AFX_MSG(CRoom101View)
> // NOTE - the ClassWizard will add and
> remove member functions here.
> //    DO NOT EDIT what you see in these
> blocks of generated code !
> //}}AFX_MSG
> DECLARE_MESSAGE_MAP()
> };

> #ifndef _DEBUG  // debug version in Room 101View.cpp
> inline CRoom101Doc* CRoom101View::GetDocument()
>    { return (CRoom101Doc*)m_pDocument; }
> #endif

> ///////////////////////////////////////////////////////////
> //////////////////

> //{{AFX_INSERT_LOCATION}}
> // Microsoft Visual C++ will insert additional
> declarations immediately before the previous line.

> #endif // !defined
> (AFX_ROOM101VIEW_H__37FC4294_AE13_4BBE_9C13_3EA19E0F97CB__I
> NCLUDED_)

> >-----Original Message-----
> >Obviously you must have changed something in that header
> file or one of the
> >files included by the view header file. You should post
> it.

> >--
> >Ajay Kalra [MVP - VC++]



> >> It's pretty much the standard view header file produced
> by
> >> AppWizard.  I have added only a few lines to it.
> >> >-----Original Message-----
> >> >What does your include file look like?

> >> >--
> >> >Ajay Kalra [MVP - VC++]


> message

> >> >> My CView file is Room 101View.h.  When I try to
> include
> >> it
> >> >> in a .cpp file, I get these errors:

> >> >> Compiling...
> >> >> Planner.cpp
> >> >> c:\hand in hand\room 101\room 101view.h(24) : error
> >> C2143:
> >> >> syntax error : missing ';' before '*'
> >> >> c:\hand in hand\room 101\room 101view.h(24) : error
> >> >> C2501: 'CRoom101Doc' : missing storage-class or type
> >> >> specifiers
> >> >> c:\hand in hand\room 101\room 101view.h(24) : error
> >> >> C2501: 'GetDocument' : missing storage-class or type
> >> >> specifiers
> >> >> Error executing cl.exe.

> >> >> Can I get an explanation?  Thanks!

> >> >.

> >.



Sun, 11 Sep 2005 23:26:24 GMT  
 trying to include CView file
Thank you so much!  But would you please explain WHY this
fixed the problem?
Quote:
>-----Original Message-----
>Try replacing the following

>class CPlanner;

>with

>class CPlanner;
>class CRoom101Doc;

>--
>Ajay Kalra [MVP - VC++]



>> Okay, below is my header file that seems to be{*filter*}
me
>> up.  When I comment out #include "Room 101View.h" in the
>> one particular cpp file, the program compiles.  Thanks.

>> // Room 101View.h : interface of the CRoom101View class
>> //
>> ////////////////////////////////////////////////////////
///
>> //////////////////

>> #if !defined

(AFX_ROOM101VIEW_H__37FC4294_AE13_4BBE_9C13_3EA19E0F97CB__I
Quote:
>> NCLUDED_)
>> #define

AFX_ROOM101VIEW_H__37FC4294_AE13_4BBE_9C13_3EA19E0F97CB__IN

- Show quoted text -

Quote:
>> CLUDED_

>> #if _MSC_VER > 1000
>> #pragma once
>> #endif // _MSC_VER > 1000

>> class CPlanner;

>> //#define WM_ACTIVITY WM_USER + 5

>> class CRoom101View : public CView
>> {
>> protected: // create from serialization only
>> CRoom101View();
>> DECLARE_DYNCREATE(CRoom101View)

>> // Attributes
>> public:
>> CRoom101Doc* GetDocument();

>> // Operations
>> public:

>> // Overrides
>> // ClassWizard generated virtual function overrides
>> //{{AFX_VIRTUAL(CRoom101View)
>> public:
>> virtual void OnDraw(CDC* pDC);  // overridden to
>> draw this view
>> virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
>> virtual void OnInitialUpdate();
>> protected:
>> virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
>> virtual void OnBeginPrinting(CDC* pDC, CPrintInfo*
>> pInfo);
>> virtual void OnEndPrinting(CDC* pDC, CPrintInfo*
>> pInfo);
>> //}}AFX_VIRTUAL

>> // Implementation
>> public:
>> CPlanner* planner;
>> void OnActivity(UINT wParam, LONG lParam);
>> virtual ~CRoom101View();

>> #ifdef _DEBUG
>> virtual void AssertValid() const;
>> virtual void Dump(CDumpContext& dc) const;
>> #endif

>> protected:

>> // Generated message map functions
>> protected:
>> //{{AFX_MSG(CRoom101View)
>> // NOTE - the ClassWizard will add and
>> remove member functions here.
>> //    DO NOT EDIT what you see in these
>> blocks of generated code !
>> //}}AFX_MSG
>> DECLARE_MESSAGE_MAP()
>> };

>> #ifndef _DEBUG  // debug version in Room 101View.cpp
>> inline CRoom101Doc* CRoom101View::GetDocument()
>>    { return (CRoom101Doc*)m_pDocument; }
>> #endif

>> ////////////////////////////////////////////////////////
///
>> //////////////////

>> //{{AFX_INSERT_LOCATION}}
>> // Microsoft Visual C++ will insert additional
>> declarations immediately before the previous line.

>> #endif // !defined

(AFX_ROOM101VIEW_H__37FC4294_AE13_4BBE_9C13_3EA19E0F97CB__I

- Show quoted text -

Quote:
>> NCLUDED_)

>> >-----Original Message-----
>> >Obviously you must have changed something in that
header
>> file or one of the
>> >files included by the view header file. You should post
>> it.

>> >--
>> >Ajay Kalra [MVP - VC++]


message

>> >> It's pretty much the standard view header file
produced
>> by
>> >> AppWizard.  I have added only a few lines to it.
>> >> >-----Original Message-----
>> >> >What does your include file look like?

>> >> >--
>> >> >Ajay Kalra [MVP - VC++]


>> message

>> >> >> My CView file is Room 101View.h.  When I try to
>> include
>> >> it
>> >> >> in a .cpp file, I get these errors:

>> >> >> Compiling...
>> >> >> Planner.cpp
>> >> >> c:\hand in hand\room 101\room 101view.h(24) :
error
>> >> C2143:
>> >> >> syntax error : missing ';' before '*'
>> >> >> c:\hand in hand\room 101\room 101view.h(24) :
error
>> >> >> C2501: 'CRoom101Doc' : missing storage-class or
type
>> >> >> specifiers
>> >> >> c:\hand in hand\room 101\room 101view.h(24) :
error
>> >> >> C2501: 'GetDocument' : missing storage-class or
type
>> >> >> specifiers
>> >> >> Error executing cl.exe.

>> >> >> Can I get an explanation?  Thanks!

>> >> >.

>> >.

>.



Mon, 12 Sep 2005 01:02:15 GMT  
 trying to include CView file

Quote:

> >Try replacing the following

> >class CPlanner;

> >with

> >class CPlanner;
> >class CRoom101Doc;

> >--
> >Ajay Kalra [MVP - VC++]

> Thank you so much!  But would you please explain WHY this
> fixed the problem?

When your h file was being compiled the compiler saw "CRoom101Doc*"
before it saw a declaration of CRoom101Doc.  So it did not recognize
that name an issued an error.  

Adding "class CRoom101Doc;" at the beginning of the file tells the
compiler "This symbol is a class name, to be defined later."  That is
enough to let it compile a pointer to the name.

--
Scott McPhillips [VC++ MVP]



Mon, 12 Sep 2005 03:05:00 GMT  
 trying to include CView file
Thank you, but I still don't get it.  This is the standard
view file created by AppWizard.  Are you saying that one
of my added lines of code was forcing the compiler to look
for the doc prematurely?  If this kind of things happens
to me again, I'd like to understand it.
Quote:
>-----Original Message-----

>> >Try replacing the following

>> >class CPlanner;

>> >with

>> >class CPlanner;
>> >class CRoom101Doc;

>> >--
>> >Ajay Kalra [MVP - VC++]

>> Thank you so much!  But would you please explain WHY
this
>> fixed the problem?

>When your h file was being compiled the compiler
saw "CRoom101Doc*"
>before it saw a declaration of CRoom101Doc.  So it did
not recognize
>that name an issued an error.  

>Adding "class CRoom101Doc;" at the beginning of the file
tells the
>compiler "This symbol is a class name, to be defined
later."  That is
>enough to let it compile a pointer to the name.

>--
>Scott McPhillips [VC++ MVP]
>.



Mon, 12 Sep 2005 12:25:54 GMT  
 trying to include CView file

Quote:

> Thank you, but I still don't get it.  This is the standard
> view file created by AppWizard.  Are you saying that one
> of my added lines of code was forcing the compiler to look
> for the doc prematurely?  If this kind of things happens
> to me again, I'd like to understand it.

The wizard is smart enough to always #include the doc file before
#include'ing the view file.  

You need to understand that this is not about wizards or MFC, it is
about the way C compilers work.  Each individual cpp file is compiled
starting with no knowledge of other files in the project.  During each
cpp compilation the compiler must see a declaration of every symbol
before it can be used.  Therefore the ordering of #include's is
important, and the forward declaration of a class name suggested in this
thread is occasionally a useful trick for declaring pointers to
not-yet-declared classes.

--
Scott McPhillips [VC++ MVP]



Mon, 12 Sep 2005 13:17:52 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Trying to use a Class derived from CView outside Frame/Doc/View

2. include file of includes

3. source for included included files

4. Why won't a include file get included some times and not other

5. Trying to include classes from .dll, getting linker error with CRuntimeClass

6. 2nd try: need a C library file for reading Windows-style .INI files

7. Trying to set .SQC files as a dependencies of .C files in Developer Studio

8. 2nd try at copying a file: copyfile() returns success but creates empty destination file

9. 2nd try at copying a file: copyfile() returns success but creates empty destination file

10. Missing includes in /usr/include/linux/*.h and /usr/include/asm.h

11. fatal error C1083: Cannot open include file: 'excpt.h': No such file or directory

12. C Header files including header files, mutually referencing typedefs

 

 
Powered by phpBB® Forum Software