|
-
Oct 23rd, 2005, 10:12 PM
#1
Thread Starter
Stuck in the 80s
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?
-
Oct 24th, 2005, 08:09 AM
#2
Frenzied Member
Re: Function Pointer Problem
Is that a mismatched brace? And why do you have a comma there?
-
Oct 24th, 2005, 01:48 PM
#3
Thread Starter
Stuck in the 80s
Re: Function Pointer Problem
Nothing changes when I remove the comma, and the brace is not misplaced.
-
Oct 24th, 2005, 07:41 PM
#4
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.
-
Oct 24th, 2005, 10:03 PM
#5
Thread Starter
Stuck in the 80s
Re: Function Pointer Problem
 Originally Posted by CornedBee
MSVC++ 6? Probably because it sucks. Use a better compiler.
Thanks, bro. Truly inspirational.
-
Oct 25th, 2005, 05:08 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|