Solved

"differs in levels of indirection from unknown-type"

Posted on 2004-10-04
8
636 Views
Last Modified: 2012-06-27
I declare a struct in PUB.h like so:

struct GLOBAL_STRUCT_G
{
      GLOBAL_STRUCT_G()
      {
            hInst                        = NULL;
            ThreadCount         = 0;
            MaxThreads                  = 200;
            hMainDlg                  = NULL;
            pMainFrame                  = NULL;
            pLeftView                  = NULL;
            pDoc                        = NULL;
            pDB                              = NULL;
      }

      HINSTANCE            hInst;
      TCHAR                  LocalComputerName[ MAX_PATH ];
      long                  ThreadCount;
      long                  MaxThreads;
      HWND                  hMainDlg;
      CMainFrame *      pMainFrame;
      CLeftView *            pLeftView;
      C_pr_temp_Doc *      pDoc;
      CDBAccess *            pDB;
};
typedef GLOBAL_STRUCT_G *stGLOBAL_STRUCT_G;

Then in MainFrm.cpp:

#include "PUB.h"

stGLOBAL_STRUCT_G p_G;

It gives me the error : error C2040: 'p_G' : 'stGLOBAL_STRUCT_G' differs in levels of indirection from ''unknown-type''
and I can't figure it out, for the life of me...
0
Comment
Question by:jd9288
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 12220601
This is odd. Try

typedef struct
{
    GLOBAL_STRUCT_G()
    {
         hInst                    = NULL;
         ThreadCount         = 0;
         MaxThreads               = 200;
         hMainDlg               = NULL;
         pMainFrame               = NULL;
         pLeftView               = NULL;
         pDoc                    = NULL;
         pDB                         = NULL;
    }

    HINSTANCE          hInst;
    TCHAR               LocalComputerName[ MAX_PATH ];
    long               ThreadCount;
    long               MaxThreads;
    HWND               hMainDlg;
    CMainFrame *     pMainFrame;
    CLeftView *          pLeftView;
    C_pr_temp_Doc *     pDoc;
    CDBAccess *          pDB;

} GLOBAL_STRUCT_G, *stGLOBAL_STRUCT_G;

instead...
0
 
LVL 17

Assisted Solution

by:rstaveley
rstaveley earned 250 total points
ID: 12220634
Compiles fine here. VC 6 and 7.1.

What line does the error correspond to?
0
 

Author Comment

by:jd9288
ID: 12220707
>>jkr
same thing...

>>What line does the error correspond to?
stGLOBAL_STRUCT_G p_G;

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:jkr
ID: 12220790
Is there any other code before that line?
0
 

Author Comment

by:jd9288
ID: 12220892
No. Here's all of it up to that line:

// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "PUB.h"

#include "_pr_temp_View.h"
#include "EnumerateShares.h"
#include "EnumerateComputers.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

stGLOBAL_STRUCT_G p_G;
0
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 12220941
Is there any chance that there's a problem with the header files? What happens if you use

#include "stdafx.h"
#include "PUB.h"

stGLOBAL_STRUCT_G p_G;

?

BTW, does

GLOBAL_STRUCT_G* p_G;

work at all?



0
 
LVL 17

Expert Comment

by:rstaveley
ID: 12220951
It's probably worth checking that you've got all your braces closed and/or completed structures with semi-colons in:

#include "EnumerateComputers.h"
0
 

Author Comment

by:jd9288
ID: 12226064
>> Is there any chance that there's a problem with the header files?
The compiler error is quite misleading, actually...
Took me a while, but the global struct var is referenced in the included files
before it's defined, so all I had to do was put the struct's declaration first:

#include "stdafx.h"
#include "PUB.h"

#include "_pr_temp_View.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

stGLOBAL_STRUCT_G p_G;

#include "EnumerateShares.h"
#include "EnumerateComputers.h"


Thank you very much!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question