Solved

"differs in levels of indirection from unknown-type"

Posted on 2004-10-04
8
635 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
  • 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
Technology Partners: 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

726 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