On Sun, Dec 7, 2008 at 4:46 AM, Dag Sverre Seljebotn
<[EMAIL PROTECTED]> wrote:
> David Cournapeau wrote:
>> Hi,
>>
>> I would like to know whether adding an IFDEF-like feature in cython
>> would be feasible ? I would like to define some cython code depending
>> on some defines in the header of the library I am wrapping.
>
> Could you tell us what your exact usecase is?

Sure. I am wrapping a library which supports several file formats: for
each format, there is an enum value:

enum {
FORMAT1,
...
FORMATN
}

New versions add some new enums, which can be used in the library. I
would like to support the new formats, without forcing people to use
the new library. For now, I hardcode the enum value for the recent
added values, but that's obviously not a nice solution.

> Some things are possible
> to do in other ways. For instance, if there's a type that's sometimes
> "long" and sometimes "short", then Cython doesn't really care about
> that, you can always use "int" in Cython anyway. There might be similar
> workarounds for whatever your case is.

it won't work in that case: I want to use a symbol which may or not
exist depending on the header version, not a symbol whose value may
change.

David
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to