[fpc-devel] void test( void *data ) to procedure test( var data ); ? is it safe ?

Hans-Peter Diettrich DrDiettrich1 at aol.com
Mon Jun 20 07:50:39 CEST 2011


Skybuck Flying schrieb:

> So now I am wondering if it's safe to convert:
>  
> void test( void *data )
>  
> to
>  
> procedure test( var data );

AFAIR this can cause problems, when the C code tests "data" for NULL.


> I don't want no strange stack problems or access violations or anything 
> like that, so I have to make sure it's 100% the same and safe ?!?

The safe way is using pointer types in OPL, for C "*" parameters.

> The convenience would be nice to have though...
>  
> My thoughts on the c/c++ inconsistency:
>  
> Prototypes for routines:
>  
> 1: void test(void *data)
> 2: void test(void &data)
>  
> The first one does compile in visual studio 2010 and the second does not.

Right. C++ "&" references never can be void or NULL, while C "*" and 
Delphi "var" (by-ref) parameters can be untyped and Nil. That's one of 
the subtle differences between C++ and OPL, which should be handled 
properly by every converter.

DoDi




More information about the fpc-devel mailing list