Professional Web Applications Themes

Same function, different parameters - UNIX Programming

"Peteris Krumins" <pkruminsREMOVETHISinbox.lv> wrote in message news:Xns93A61DDE5838whitesuneapollolv130.133.1.4. .. > I am wondering how this could be done the best: > for example, functions (printf, vprintf), (fprintf, vfprintf) > one of the pair takes ..., the other va_list as the last parameter. > How is a change in the source file done? If some improvements are made to > the first function in the pair the same should be done in the second, so > the same source has to be typed twice. The function that takes variable arguments calls the va_list function. For example: int SomeFunctionVA(const char *c, va_list ap) ...

  1. #1

    Default Re: Same function, different parameters


    "Peteris Krumins" <pkruminsREMOVETHISinbox.lv> wrote in message
    news:Xns93A61DDE5838whitesuneapollolv130.133.1.4. ..
    > I am wondering how this could be done the best:
    > for example, functions (printf, vprintf), (fprintf, vfprintf)
    > one of the pair takes ..., the other va_list as the last parameter.
    > How is a change in the source file done? If some improvements are made
    to
    > the first function in the pair the same should be done in the second, so
    > the same source has to be typed twice.
    The function that takes variable arguments calls the va_list function.
    For example:

    int SomeFunctionVA(const char *c, va_list ap)
    {
    // the real code goes here
    }

    int SomeFunction(const char *c, ...)
    {
    va_list ap;
    va_start(ap, c);
    int ret=SomeFunctionVA(c, ap);
    va_end(ap);
    return ret;
    }

    DS


    David Schwartz Guest

  2. #2

    Default Re: Same function, different parameters

    "David Schwartz" <davidswebmaster.com> wrote in
    news:bdddhj$4rh$1nntp.webmaster.com:
    > "Peteris Krumins" <pkruminsREMOVETHISinbox.lv> wrote in message
    > news:Xns93A61DDE5838whitesuneapollolv130.133.1.4. ..
    >
    > [...]
    >
    > The function that takes variable arguments calls the va_list
    > function.
    > For example:
    >
    > int SomeFunctionVA(const char *c, va_list ap)
    > {
    > // the real code goes here
    > }
    >
    > int SomeFunction(const char *c, ...)
    > {
    > va_list ap;
    > va_start(ap, c);
    > int ret=SomeFunctionVA(c, ap);
    > va_end(ap);
    > return ret;
    > }
    Thanks!


    P.Krumins
    Peteris Krumins Guest

Similar Threads

  1. #40182 [NEW]: Want a function strpos_all with optional parameters
    By krudtaa at yahoo dot com in forum PHP Bugs
    Replies: 0
    Last Post: January 20th, 07:26 PM
  2. Calling a function with many parameters
    By nitai_co in forum Macromedia ColdFusion
    Replies: 1
    Last Post: June 15th, 12:35 AM
  3. XMLTransform function with parameters
    By einfo in forum Macromedia ColdFusion
    Replies: 3
    Last Post: February 24th, 01:43 PM
  4. Function Parameters
    By Oluwatope Akinniyi in forum PostgreSQL / PGSQL
    Replies: 4
    Last Post: January 2nd, 09:21 PM
  5. Function definition with optional parameters?
    By Phester in forum PHP Development
    Replies: 4
    Last Post: September 28th, 09:27 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139