atilaneves / dpp

Directly include C headers in D source code
Boost Software License 1.0
227 stars 31 forks source link

SuiteSparse GraphBLAS.h works with a minor issue #303

Closed michelp closed 2 years ago

michelp commented 2 years ago

I was able to compile and link the SuiteSparse GraphBLAS library and create a simple sparse matrix wrapper with no problems, which is amazing given that it's thousands of symbols, dpp is pretty cool!

https://github.com/michelp/Daphony/blob/main/src/main.dpp

but when using the library macro GxB_INDEX_MAX I get the following error:

./matrix.d(119): Error: undefined identifier `GxB_INDEX_MAX`

So instead I hardcode that constant:

https://github.com/michelp/Daphony/blob/main/src/suitesparse.dpp#L3

the C definition for the macro is here:

https://github.com/DrTimothyAldenDavis/GraphBLAS/blob/stable/Include/GraphBLAS.h#L262

and it gets converted to D as:

    static if(!is(typeof(GxB_INDEX_MAX))) {
        private enum enumMixinStr_GxB_INDEX_MAX = `enum GxB_INDEX_MAX = ( cast( GrB_Index ) ( 1ULL << 60 ) );`;
        static if(is(typeof({ mixin(enumMixinStr_GxB_INDEX_MAX); }))) {
            mixin(enumMixinStr_GxB_INDEX_MAX);
        }
    }

I'm sorry I've only been using D for a few days, so I'm not entirely clear on what is wrong with the definition. I have a workaround for it but figured I'd point it out. Thanks!

atilaneves commented 2 years ago

Ah. I think this is due to the ULL. This should actually not be hard to fix.

michelp commented 2 years ago

Thanks for the quick fix!