FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour C-Problem
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
C-Problem
Posted: Thu Dec 15, 2011 01:41 PM
Question to the C-programmers:
The following C-code-snippet is included in a harbour-function (HB_FUNC( TEST ). Now i must give the "Mc5Message81C" a value. But with hb_parc( 1 ) or so a compiler-error occurs. Whats the right parameter-conversion?

Code (fw): Select all Collapse
struct Mc5Message81D {
    Mc5MsgHead h; // Kopf
    union {
        Mc5TargetDataD targetL; // Daten
    };
};

class Mc5Message81C: public Mc5Message81D {
  public:
    Mc5Message81C( void )
    {
      clear();
    }
    ~Mc5Message81C( void )
    {
    }
Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: C-Problem
Posted: Thu Dec 15, 2011 01:48 PM
Günther,

Code (fw): Select all Collapse
Mc5Message81C mc5 = new Mc5Message81C();

Mc5Message81D mc5m;

mc5m.h = ( Mc5MsgHead ) hb_parnl( 1 );
memcpy( ( unsigned char * ) mc5m.targetL, ( unsigned char * ) hb_parnd( 2 ), sizeof( Mc5TargetDataD ) );


Not sure if that is what you are looking for. Is targetL a string or a number ? I have assumed that it is a string
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: C-Problem
Posted: Thu Dec 15, 2011 02:16 PM
Antonio, thanks! The above code is from the headerfile.
This is code from my function. The first parameter is a string and should assigned to mtlg. But I cannot convert the string-parameter to mtlg

Code (fw): Select all Collapse
HB_FUNC (TEST) 
Mc5Message81C mtlg;
Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: C-Problem
Posted: Thu Dec 15, 2011 04:54 PM

Günther,

But Mc5Message81C is a Class name, why do you want to fill an object with a string ?

Do you want to replace the contents of the object ?

Do you have some example code ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: C-Problem
Posted: Thu Dec 15, 2011 08:26 PM
Antonio, this is the original code from the example. I mean, if in the recvfrom() the "&mtlg" is filled with the data from network, this must be a string!?

Code (fw): Select all Collapse
. 
Mc5Message81C mtlg;
.
.
   if( (laengeMtlg = recvfrom( sock, &mtlg, sizeof(mtlg), MSG_OOB, (struct sockaddr *) &cltIpAdr, &cltIpAdrLaenge )) > 0 )
.
.
Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: C-Problem
Posted: Thu Dec 15, 2011 08:51 PM

Günther,

Use memcpy( unsigned char * destination, unsiged char * source, int size )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: C-Problem
Posted: Fri Dec 16, 2011 08:42 AM

Antonio, thanks very much!

Regards,
Günther
---------------------------------
office@byte-one.com

Continue the discussion