porting a c function to c++

Discussion in 'C++' started by cfn, May 5, 2006.

  1. cfn

    cfn Guest

    Hi,

    I want 2 port a cfunction to c++.

    My question is that I do not know how to handle the arrays in the
    parameterlist in the following function. (int imins[2][2],jmins[2][2];)

    Can someone please tell me how to write this in a c++ manner?
    To be more exact: how do I handle the static arrays in the
    parameterlist?

    regards
    Christofer


    .....
    static void frame_estimate(org,ref,mb,i,j,sx,sy,
    iminp,jminp,imintp,jmintp,iminbp,jminbp,dframep,dfieldp,tselp,bselp,
    imins,jmins)
    unsigned char *org,*ref,*mb;
    int i,j,sx,sy;
    int *iminp,*jminp;
    int *imintp,*jmintp,*iminbp,*jminbp;
    int *dframep,*dfieldp;
    int *tselp,*bselp;
    int imins[2][2],jmins[2][2];
    {
    int dt,db,dmint,dminb;
    int imint,iminb,jmint,jminb;

    /* frame prediction */
    *dframep = fullsearch(org,ref,mb,width,i,j,sx,sy,16,width,height,
    iminp,jminp);
    .....
    cfn, May 5, 2006
    #1
    1. Advertising

  2. cfn

    osmium Guest

    "cfn" writes:

    > Hi,
    >
    > I want 2 port a cfunction to c++.


    If you can't find time in your busy day to write a question, why in God's
    name do you think we can find time to answer it??

    <SNIP>
    osmium, May 5, 2006
    #2
    1. Advertising

  3. cfn

    Tomás Guest


    > static void frame_estimate(org,ref,mb,i,j,sx,sy,
    > iminp,jminp,imintp,jmintp,iminbp,jminbp,dframep,dfieldp,tselp,bselp,
    > imins,jmins)
    > unsigned char *org,*ref,*mb;
    > int i,j,sx,sy;
    > int *iminp,*jminp;
    > int *imintp,*jmintp,*iminbp,*jminbp;
    > int *dframep,*dfieldp;
    > int *tselp,*bselp;
    > int imins[2][2],jmins[2][2];
    > {
    > int dt,db,dmint,dminb;
    > int imint,iminb,jmint,jminb;
    >
    > /* frame prediction */
    > *dframep = fullsearch(org,ref,mb,width,i,j,sx,sy,16,width,height,
    > iminp,jminp);



    namespace {

    void frame_estimate(unsigned char *org, unsigned char *ref, unsigned char
    *mb, int i, int j,
    int sx, int sy, int *iminp, int *jminp, int *imintp,int *jmintp,int
    *iminbp,int *jminbp,
    int *dframep,int *dfieldp,int *tselp,int *bselp, int imins[2][2], int
    jmins[2][2] )
    {
    return;
    }

    }


    -Tomás
    Tomás, May 5, 2006
    #3
  4. cfn

    Puppet_Sock Guest

    cfn wrote:
    > I want 2 port a cfunction to c++.


    Tomás has answered your specific question. All you really *need*
    to do is change from the very old style parameter list to the new
    style parameter list, then carry on as usual.

    [snip]
    > static void frame_estimate(org,ref,mb,i,j,sx,sy,
    > iminp,jminp,imintp,jmintp,iminbp,jminbp,dframep,dfieldp,tselp,bselp,
    > imins,jmins)
    > unsigned char *org,*ref,*mb;
    > int i,j,sx,sy;
    > int *iminp,*jminp;
    > int *imintp,*jmintp,*iminbp,*jminbp;
    > int *dframep,*dfieldp;
    > int *tselp,*bselp;
    > int imins[2][2],jmins[2][2];
    > {


    So all you really need to do here is get each of those things after the
    closing ) up into the ( ) list.

    Now, if all you want to do is get some legacy code to run under your
    shiny new C++ compiler, that is probably enough. And if that's all
    you care about, the rest of this post is probably a waste of your time.
    (Oh, you probably don't want the keyword static.)

    But! If you want to do some work you can make a much better
    program. For example, this function makes me think that a class
    called frame with a member function called estimate are good
    candiates. Then many of those parameters could become
    data members of the class and get removed from the param
    list. 19 parameters to a function is probably too many. If
    it was a class, you might be able to have this function have
    as few as two parameters, and possibly return the result
    as the function's return value instead of through one of
    its arguments. (I'm guessing that a function called estimate
    is not *just* called for side effects.)

    So, if you have the budget for a restructuring, you might find that
    you can improve your code a lot by doing more than a simple
    porting. But before you jump at that, it would be a *lot* of work.
    Socks
    Puppet_Sock, May 5, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Overworked

    HELP - Porting to .NET path?

    Overworked, Jan 23, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    384
    Chad Z. Hower aka Kudzu
    Jan 23, 2004
  2. Nate
    Replies:
    2
    Views:
    413
    Yan-Hong Huang[MSFT]
    Feb 18, 2004
  3. Patrick
    Replies:
    6
    Views:
    850
    Roedy Green
    Jul 13, 2004
  4. dd
    Replies:
    2
    Views:
    367
    tmp123
    Mar 28, 2006
  5. kj
    Replies:
    10
    Views:
    450
Loading...

Share This Page