On Fri, 17 Jul 2009, Lorenzo Fiorini wrote:
> I have this code since years, with latest svn it gives:
> assignment discards qualifiers from pointer target type
> How can I pacify the warning without breaking Clipper compatibility?
[...]
   const char * t;
it allows also to detect illegal (in Clipper too) write access to 't' string.
If above is a problem then we can also change in extend.api:
   #define _parc           hb_parvc
to:
   #define _parc           ( char * ) hb_parvc

BTW I suggest to define some macros for Clipper builds rather using
macros in Harbour ones, i.e.:

   /*** hbapi.h for CA-Cl*pper */
   #ifndef _HBAPI_H
      #define _HBAPI_H
      #define HB_FUNC( fun )     CLIPPER fun()
      #define hb_parc( n )       _parc( n, 0 )
      #define hb_retnd( n )      _retnd( n )
      [...]
   #endif /* _HBAPI_H */

and then simply use code like:

   #include "hbapi.h"
   HB_FUNC( REALIEE )
   {
       int i;
       const char *t;

       t = hb_parc(1);

       for (i = 0; i < 8; i++)
           v.s[i] = *t++;

       hb_retnd( v.n );
   }


Harbour API is much more friendly for C preprocessor so if you define
your own hbapi.h for Clipper then later you do not have to use any
#ifdef __HARBOUR__ in your C code.
BTW maybe someone can define such hbapi.h for Clipper so we can add it
to SVN.
BTW for x86 CPUs without strict alignment you can use this hacked code:
   HB_FUNC( REALIEE )
   {
       hb_retnd( * ( double * ) hb_parc( 1 ) );
   }
but if you want to make this code really platform independent then you
should use:
   HB_FUNC( REALIEE )
   {
       hb_retnd( hb_get_ieee754( ( const BYTE * ) hb_parc( 1 ) ) );
   }

best regards,
Przemek
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to