error C2040: 'hFlag' : 'void *' differs in levels of indirection from 'int'

Discussion in 'C++' started by Angus, Feb 12, 2007.

  1. Angus

    Angus Guest

    I am using a global which is a void*

    I have it defined in one file as:
    void* hFlag;


    and one other header file as:
    extern void* hFlag;


    But I get this compile error:


    error C2040: 'hFlag' : 'void *' differs in levels of indirection from
    'int'


    I can't understand what the problem is. I have another global
    variable which is not void* and that works ok. I assume void* is the
    problem. How can I fix it?
     
    Angus, Feb 12, 2007
    #1
    1. Advertising

  2. Angus

    Ron Natalie Guest

    Re: error C2040: 'hFlag' : 'void *' differs in levels of indirectionfrom 'int'

    Angus wrote:

    >
    > error C2040: 'hFlag' : 'void *' differs in levels of indirection from
    > 'int'
    >
    >
    > I can't understand what the problem is. I have another global
    > variable which is not void* and that works ok. I assume void* is the
    > problem. How can I fix it?
    >

    Somewhere you have hFlag defined as int, or it picked up some inmplicit
    int declaration (not supposedly possible in C++).

    Are you sure there's not an:
    extern hFlag;
    somewhere?
     
    Ron Natalie, Feb 12, 2007
    #2
    1. Advertising

  3. Re: error C2040: 'hFlag' : 'void *' differs in levels of indirectionfrom 'int'

    Angus wrote:
    > I am using a global which is a void*


    I've already responded to your question in comp.lang.c. Please, either
    learn to cross-post properly or do not cross-post at all. (BTW,
    cross-posting between comp.lang.c and comp.lang.c++ is rarely
    appropriate, as C and C++ are two different languages)

    --
    Clark S. Cox III
     
    Clark S. Cox III, Feb 12, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tobias Erbsland
    Replies:
    2
    Views:
    15,768
    Tobias Erbsland
    Jun 18, 2004
  2. Ollej Reemt
    Replies:
    7
    Views:
    567
    Jack Klein
    Apr 22, 2005
  3. blimeyoreilly
    Replies:
    10
    Views:
    4,559
    Peter Julian
    Jun 26, 2005
  4. Angus
    Replies:
    6
    Views:
    1,337
    matevzb
    Feb 12, 2007
  5. Maxx

    Error C2040

    Maxx, Oct 15, 2009, in forum: C Programming
    Replies:
    6
    Views:
    1,396
    James Kuyper
    Oct 20, 2009
Loading...

Share This Page