Trouble in converting C code to D
Jacob Carlborg via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Apr 12 08:41:05 PDT 2015
On 2015-04-12 11:53, Suliman wrote:
> But could you explain why if binding have next string:
>
> enum CPLErr
> {
> CE_None = 0,
> CE_Debug = 1,
> CE_Warning = 2,
> CE_Failure = 3,
> CE_Fatal = 4
> }
>
> I can't use:
> if( GDALGetGeoTransform( hDataset, adfGeoTransform.ptr ) == CE_None )
In D you need to include the name of the enum type as well:
CPLErr.CE_None. If you want to avoid that you can use aliases:
alias CE_None = CPLErr.CE_None
Or the with-statement:
with (CPLErr)
{
// inside this block all the members of CPLErr can be accessed
without prefixing them with CPLErr
if( GDALGetGeoTransform( hDataset, adfGeoTransform.ptr ) == CE_None )
{
}
}
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list