Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macros defining integer constants using expressions containing enum values don't work #258

Open
heycam opened this issue Nov 15, 2016 · 6 comments

Comments

@heycam
Copy link
Contributor

heycam commented Nov 15, 2016

In Gecko (in gfxFontConstants.h) we have:

enum {
    eFeatureAlternates_historical,
    eFeatureAlternates_stylistic,
    eFeatureAlternates_styleset,
    eFeatureAlternates_character_variant,
    eFeatureAlternates_swash,
    eFeatureAlternates_ornaments,
    eFeatureAlternates_annotation,

    eFeatureAlternates_numFeatures
};

#define NS_FONT_VARIANT_ALTERNATES_HISTORICAL        (1 << eFeatureAlternates_historical)

rust-bindgen doesn't generate anything for NS_FONT_VARIANT_ALTERNATES_HISTORICAL.

@heycam
Copy link
Contributor Author

heycam commented Nov 15, 2016

cc @emilio

@emilio
Copy link
Contributor

emilio commented Nov 15, 2016

Ugh, this never worked though... I know how to fix it for this case, but it's not pretty, and it's definitely hard to make it work for the general case.

@emilio
Copy link
Contributor

emilio commented Nov 15, 2016

If only clang gave us a way of evaluating an expression in a given context...

@emilio
Copy link
Contributor

emilio commented Nov 15, 2016

Yeah, so I looked into patching libclang so it works, but I can't see a clear way to do this. Basically, clang needs to expand the macro so it knows in what context to evaluate it. You can convert that into a constant, and then I think I can do stuff with it.

@emilio
Copy link
Contributor

emilio commented Nov 16, 2016

FWIW, if those are switched to constants, they'll work properly with #260, even though it's a complex expression.

@pheki
Copy link
Contributor

pheki commented Oct 21, 2021

Just to point out other uses / problems, the same underlying problem happen for "function aliases" defines, such as some functions in monocypher.

I didn't open a new issue since you've already merged #1546, which is the same but with structs, into this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants