callback issue<mingw compiler error : expected unqualified-id before '=' token>
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: callback issue<mingw compiler error : expected unqualified-id before '=' token>

  1. #1
    Join Date
    Jan 2009
    Location
    new york,usa
    Posts
    49

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,276

    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"
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Jan 2009
    Location
    new york,usa
    Posts
    49

    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

  4. #4
    Join Date
    Jan 2009
    Location
    new york,usa
    Posts
    49

    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

  5. #5
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,276

    Re: callback issue<mingw compiler error : expected unqualified-id before '=' token>

    You're looking at the size of a function pointer.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  6. #6
    Join Date
    Jan 2009
    Location
    new york,usa
    Posts
    49

    Re: callback issue<mingw compiler error : expected unqualified-id before '=' token>

    kewl. so how would i find the actual size of the function?

  7. #7
    Join Date
    Feb 2002
    Posts
    4,640

    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

  8. #8
    Join Date
    Apr 1999
    Posts
    27,427

    Re: callback issue<mingw compiler error : expected unqualified-id before '=' token>

    Quote Originally Posted by tzadik View Post
    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

  9. #9
    Join Date
    Apr 2007
    Location
    Mars NASA Station
    Posts
    1,436

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center