Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > porting a c function to c++

Reply
Thread Tools

porting a c function to c++

 
 
cfn
Guest
Posts: n/a
 
      05-05-2006
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,df ieldp,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,hei ght,
iminp,jminp);
.....

 
Reply With Quote
 
 
 
 
osmium
Guest
Posts: n/a
 
      05-05-2006
"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>


 
Reply With Quote
 
 
 
 
Tomás
Guest
Posts: n/a
 
      05-05-2006

> static void frame_estimate(org,ref,mb,i,j,sx,sy,
> iminp,jminp,imintp,jmintp,iminbp,jminbp,dframep,df ieldp,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,hei ght,
> 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
 
Reply With Quote
 
Puppet_Sock
Guest
Posts: n/a
 
      05-05-2006
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,df ieldp,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

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help porting Perl function kj Python 10 06-08-2008 04:52 PM
on variadic function in C when porting matlab files to C dd C Programming 2 03-28-2006 02:38 PM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
Help with FileInputStream and DataInputStream - porting c++ fread function into Java Patrick Java 6 07-13-2004 06:22 PM
HELP - Porting to .NET path? Overworked ASP .Net 2 01-23-2004 10:15 PM



Advertisments