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
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.
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
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
Re: callback issue<mingw compiler error : expected unqualified-id before '=' token>
You're looking at the size of a function pointer.
Re: callback issue<mingw compiler error : expected unqualified-id before '=' token>
kewl. so how would i find the actual size of the function?
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
Re: callback issue<mingw compiler error : expected unqualified-id before '=' token>
Quote:
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
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.