Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Pointer to function with variable argument list

Pointer to function with variable argument list

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Crazy Joe Devola
    wrote on last edited by
    #1

    Hi, I am writing a wrapper for a DLL that has 2 functions: int func1(long p1); int func2(char *p1, ...); The wrapper creates pointes to the two functions: int (* pfunc1)(long p1); int (* pfunc2)(char *p1, ...); To call function 1 I do: wrapper.pfunc1(1234); My problem is: how do I call func2 using the pointer? Sometimes I may pass 1 parameters, sometimes 2 or 3 or 4, and the data types may change. Is it possible at all to do this? Thanks

    P 1 Reply Last reply
    0
    • C Crazy Joe Devola

      Hi, I am writing a wrapper for a DLL that has 2 functions: int func1(long p1); int func2(char *p1, ...); The wrapper creates pointes to the two functions: int (* pfunc1)(long p1); int (* pfunc2)(char *p1, ...); To call function 1 I do: wrapper.pfunc1(1234); My problem is: how do I call func2 using the pointer? Sometimes I may pass 1 parameters, sometimes 2 or 3 or 4, and the data types may change. Is it possible at all to do this? Thanks

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      yaron klodovski wrote:

      how do I call func2 using the pointer?

      same as you are using pfunc1.

      yaron klodovski wrote:

      Sometimes I may pass 1 parameters, sometimes 2 or 3 or 4, and the data types may change.

      you need to assign address of function having prototype same as function pointer.

      i.e. function may look like this
      int foo(char*,int);
      or
      int foo(char*,char*,int);

      Prasad Notifier using ATL

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups