Results 1 to 6 of 6

Thread: Function Pointer Problem

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Function Pointer Problem

    Function pointers and callbacks? Argh! Does anyone know why this won't compile on MSVC++, but will with GCC?

    Code:
    	template<class T>
    static Entity *instantiateEntity(IGame *g, Vector v)
    {
    	return new T(g, v);
    }
    
    static itemspec_t items[] = {
    	{
    		"player_start",
    		{NULL},
    		{NULL},
    		instantiateEntity<Player>
    	},
    };
    MS says:

    error C2440: 'initializing' : cannot convert from '' to 'class Entity *(__cdecl *)(class IGame *,struct Vector)'
    None of the functions with this name in scope match the target type
    And points to the bolded line. Any ideas?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037

    Re: Function Pointer Problem

    Is that a mismatched brace? And why do you have a comma there?

  3. #3

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Function Pointer Problem

    Nothing changes when I remove the comma, and the brace is not misplaced.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Function Pointer Problem

    MSVC++ 6? Probably because it sucks. Use a better compiler.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Function Pointer Problem

    Quote Originally Posted by CornedBee
    MSVC++ 6? Probably because it sucks. Use a better compiler.
    Thanks, bro. Truly inspirational.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Function Pointer Problem

    Meh. Not my fault the compiler you're using is 8 years old. If you used Windows98, would you complain if it didn't support the funky new gadget you just bought?

    The toolkit of VC++7.1 is freely downloadable. Somebody even managed to plug it into the 6 IDE after a fashion; search the archives.
    Or get Dev-C++, which uses a good GCC.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width