CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • SQL Server Modeling Services with Microsoft Visual Studio 2010 Beta 2
  • Faltering Windows support
  • Internet Explorer 8 Click Clever Click Safe
  • Release Candidate 2 for ASP.NET MVC 2

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > C++ (Non Visual C++ Issues)
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    C++ (Non Visual C++ Issues) Ask or answer C and C++ questions not related to Visual C++. This includes Console programming, Linux programming, or general ANSI C++.

     
     
    Thread Tools Search this Thread Rate Thread Display Modes
    Prev Previous Post   Next Post Next
      #1    
    Old October 21st, 2009, 09:27 AM
    chacham15 chacham15 is offline
    Junior Member
     
    Join Date: Jan 2007
    Posts: 5
    chacham15 is an unknown quantity at this point (<10)
    Reflection

    I know that this isnt the C forum, but there wasnt one and technically C is a subset of C++ so keep that in mind. Im implementing reflection in my system and I have half of the job done. I currently have the compiler run a program that I buid which parses header files. It takes the function name of each function a creates a c file containing an two parallel arrays, one with function name, the other with the function pointer.

    Example output:

    char* function_names[] = {"main (int, char**)", "foo (int)", "bar (double)"};
    void* function_pointers[] = {&main, &foo, &bar};

    This part works perfectly. The hard part is writing the following function:

    void run_function(void (*fnptr)(), ...){

    }

    The function pointer type is obviously not the correct one since it can vary. I know how to pull the arguments off of the stack since i have the prototypes of the functions. What I'm missing is how to actually call the function. Do I have to go to pushing arguments onto the stack with assembly?

    Thanks!
    Chacham15
    Reply With Quote
     

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > C++ (Non Visual C++ Issues)


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 12:11 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.