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. Wrapper to function with varargs

Wrapper to function with varargs

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
4 Posts 3 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.
  • K Offline
    K Offline
    Kri5
    wrote on last edited by
    #1

    I have a function in a DLL which takes varargs. I only have the header file of the DLL. Is there a way how i can provide a wrapper for the function with varargs? For e.g. if the function definition is as follows: int average( int first, ... ); // calculate average of a series of integers ..how can i provide a wrapper for it? I'm stuck here: int averageWrap(int first, .../*how do i handle varargs here?*/) { return average(first, ... /*how do i pass the varargs params?*/); } Thanks _________________________ Kri5 -- modified at 5:50 Thursday 13th April, 2006

    R C 2 Replies Last reply
    0
    • K Kri5

      I have a function in a DLL which takes varargs. I only have the header file of the DLL. Is there a way how i can provide a wrapper for the function with varargs? For e.g. if the function definition is as follows: int average( int first, ... ); // calculate average of a series of integers ..how can i provide a wrapper for it? I'm stuck here: int averageWrap(int first, .../*how do i handle varargs here?*/) { return average(first, ... /*how do i pass the varargs params?*/); } Thanks _________________________ Kri5 -- modified at 5:50 Thursday 13th April, 2006

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      Have a look at the functions va_arg, va_end, va_start. ~RaGE();

      K 1 Reply Last reply
      0
      • R Rage

        Have a look at the functions va_arg, va_end, va_start. ~RaGE();

        K Offline
        K Offline
        Kri5
        wrote on last edited by
        #3

        Those are for iterating through the parameters one by one. I need to be able to fetch them and pass them on to the function i am wrapping...i don't think those functions can help me. :( _________________________ Kri5 -- modified at 9:04 Thursday 13th April, 2006

        1 Reply Last reply
        0
        • K Kri5

          I have a function in a DLL which takes varargs. I only have the header file of the DLL. Is there a way how i can provide a wrapper for the function with varargs? For e.g. if the function definition is as follows: int average( int first, ... ); // calculate average of a series of integers ..how can i provide a wrapper for it? I'm stuck here: int averageWrap(int first, .../*how do i handle varargs here?*/) { return average(first, ... /*how do i pass the varargs params?*/); } Thanks _________________________ Kri5 -- modified at 5:50 Thursday 13th April, 2006

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          i'm not sure you can. many libraries that export "..." functions also export va_list versions specifically so people can build layers on top of those functions. Cleek | Image Toolkits | Thumbnail maker

          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