Board index » delphi » enum from delphi to c++ Z4 directive does not work

enum from delphi to c++ Z4 directive does not work

Hi,

I tried to use all the Z directive  Z1 Z2 Z4 none of them work correctly
when passing enum from delphi to c++.

Following  is an example how I have used the Z directive .

implementation

{$R *.DFM}
{$Z4} {$MINENUMSIZE 2}   // or any other combination of $Z and
$$MINENUMSIZE
.
.
Have I used it correctly ?

Thanks ,

Eyal

 

Re:enum from delphi to c++ Z4 directive does not work


Quote
In article <01be0173$bfa3c340$c7cc74c0@m-e-a>, Eyal  wrote:
> {$Z4} {$MINENUMSIZE 2}   // or any other combination of $Z and
> $$MINENUMSIZE
> ..
> ..
> Have I used it correctly ?

No. Use *either* $MINENUMSIZE *or* $Z, they are aliases for the same thing.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitely requested!

Re:enum from delphi to c++ Z4 directive does not work


Hi,
I have used the Z directive as explained but c++ still does not recognize
the enum variable correctly.
Do have any other idea why does it happen ?
Thanks,
Eyal.

Peter Below <100113.1...@compuserve.com> wrote in article
<VA.0000204d.0103d395@petersnewbox>...

Quote
> In article <01be0173$bfa3c340$c7cc74c0@m-e-a>, Eyal  wrote:
> > {$Z4} {$MINENUMSIZE 2}   // or any other combination of $Z and
> > $$MINENUMSIZE
> > ..
> > ..
> > Have I used it correctly ?

> No. Use *either* $MINENUMSIZE *or* $Z, they are aliases for the same
thing.

> Peter Below (TeamB)  100113.1...@compuserve.com)
> No e-mail responses, please, unless explicitely requested!

Re:enum from delphi to c++ Z4 directive does not work


Quote
> I have used the Z directive as explained but c++ still does not recognize
> the enum variable correctly.
> Do have any other idea why does it happen ?

Sorry, i don't know enough about the peculiarites of C++ compilers to come
up with another suggestion.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitely requested!

Re:enum from delphi to c++ Z4 directive does not work


I have used the following successfully
combining Delphi with my C++:

{$Z4}
type
 CSDM = (CSDM_OFF, CSDM_ON);
{$Z4}
type
 CSLD = (CSLD_NO, CSLD_YES);
{$Z4}
type
 CSEI = (CSEI_NO, CSEI_YES);

You might be having problems with the default packing sizes
in C++.  It might be packing on eight byte boundaries.

Try a #pragma pack (4) - or 2 or 1 or 8
inside your 'C' header file to align the sizes to match
your {$Zn} directive in Delphi.

Quote
Peter Below <100113.1...@compuserve.com> wrote in message ...
>> I have used the Z directive as explained but c++ still does not recognize
>> the enum variable correctly.
>> Do have any other idea why does it happen ?

>Sorry, i don't know enough about the peculiarites of C++ compilers to come
>up with another suggestion.

>Peter Below (TeamB)  100113.1...@compuserve.com)
>No e-mail responses, please, unless explicitely requested!

Re:enum from delphi to c++ Z4 directive does not work


Oh yeah, one other thing, make sure that you close
the #pragma pack (n) with:

#pragma pack ()

at the end of the header file.  That will restore the
default packing / sizing.

Quote
Jeff Hellzen wrote in message <71as1l$j...@forums.borland.com>...
>I have used the following successfully
>combining Delphi with my C++:

>{$Z4}
>type
> CSDM = (CSDM_OFF, CSDM_ON);
>{$Z4}
>type
> CSLD = (CSLD_NO, CSLD_YES);
>{$Z4}
>type
> CSEI = (CSEI_NO, CSEI_YES);

>You might be having problems with the default packing sizes
>in C++.  It might be packing on eight byte boundaries.

>Try a #pragma pack (4) - or 2 or 1 or 8
>inside your 'C' header file to align the sizes to match
>your {$Zn} directive in Delphi.

>Peter Below <100113.1...@compuserve.com> wrote in message ...
>>> I have used the Z directive as explained but c++ still does not
recognize
>>> the enum variable correctly.
>>> Do have any other idea why does it happen ?

>>Sorry, i don't know enough about the peculiarites of C++ compilers to come
>>up with another suggestion.

>>Peter Below (TeamB)  100113.1...@compuserve.com)
>>No e-mail responses, please, unless explicitely requested!

Other Threads