-
March 11th, 2009, 03:04 PM
#1
callback issue<mingw compiler error : expected unqualified-id before '=' token>
hey,
i just wanted to find the size of an overloaded function and got trapped in callback land...
Code:
#include<iostream>
using namespace std;
void f(int,int,double);
void f(int,int);
int main(void) {
void (*p)(int,int,double);
p = f;
cout << sizeof(p) << endl;
}
void f(int i,int j, double k){
cout << "test0" << endl;
}
i can't see what it's asking for and google isn't helping... thanks in advance
n
-
March 11th, 2009, 03:07 PM
#2
Re: callback issue<mingw compiler error : expected unqualified-id before '=' token>
Your sample program compiled without errors (and only had false alarm warnings) for me when I tested with the MinGW port of g++ 3.4.5, MSVC8 and the Comeau online compiler.
Last edited by laserlight; March 11th, 2009 at 03:19 PM.
Reason: insert "only had"
-
March 11th, 2009, 03:18 PM
#3
Re: callback issue<mingw compiler error : expected unqualified-id before '=' token>
sorry about that, my school has restrictions in place for environmental variables(xp), so i got eclipse set up for C++ with Mingw today and i'm just getting used to it. i forgot to save the file. thanks for looking...
n
-
March 11th, 2009, 03:26 PM
#4
Re: callback issue<mingw compiler error : expected unqualified-id before '=' token>
size = 4?
okay, stop me if i'm wrong, but shouldn't memory be set aside for two(2) ints and a double? could someone explain what it is i'm seeing. thanks again.
n
Last edited by tzadik; March 11th, 2009 at 03:29 PM.
Reason: added: n't
-
March 11th, 2009, 03:28 PM
#5
Re: callback issue<mingw compiler error : expected unqualified-id before '=' token>
You're looking at the size of a function pointer.
-
March 11th, 2009, 03:44 PM
#6
Re: callback issue<mingw compiler error : expected unqualified-id before '=' token>
kewl. so how would i find the actual size of the function?
-
March 11th, 2009, 04:21 PM
#7
Re: callback issue<mingw compiler error : expected unqualified-id before '=' token>
Define "actual size of the function"... Functions are code, and really don't have any size (except whatever the chunk of assembly code takes up).
Viggy
-
March 12th, 2009, 03:44 AM
#8
Re: callback issue<mingw compiler error : expected unqualified-id before '=' token>
Originally Posted by tzadik
hey,
i just wanted to find the size of an overloaded function
What sizeof() gets you is the size in bytes of the variable type. Since f is a pointer, it gets you the number of bytes a pointer consists of.
As MrViggy stated, what do you mean by "size of an overloaded function"? If you mean code size, this is totally outside the realm of ANSI C++. If anything, getting the "size of a function" in terms of code size is OS dependent, where you have to know which OS function(s) to call to get this information.
Regards,
Paul McKenzie
-
March 13th, 2009, 05:05 AM
#9
Re: callback issue<mingw compiler error : expected unqualified-id before '=' token>
I think there are one section in assembly that contain all your code. I forgot those name.
Thanks for your help.
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
|