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

Generate multiple variants for conditional compilation #72

Open
edsko opened this issue Aug 3, 2024 · 1 comment
Open

Generate multiple variants for conditional compilation #72

edsko opened this issue Aug 3, 2024 · 1 comment
Labels
enhancement New feature or request priority: low

Comments

@edsko
Copy link
Collaborator

edsko commented Aug 3, 2024

Suppose we have a C header such as

#ifdef EXTENDED
#   define MAX_LEN 75
#else
#   define MAX_LEN 50
#endif

we have two ways to proceed:

  • We could resolve the condition when we generate the headers: the value of EXTENDED would have to be known when we generate the headers. This is far by the simpler option, and should probably be the default
  • We could delay the decision, and generate Haskell code that relies on the same condition:
maxLen :: forall a. fromCIntegerConstant a => a
#ifdef EXTENDED
maxLen = fromCIntegerConstant 75
#else
maxLen = fromCIntegerConstant 50
#endif
@edsko
Copy link
Collaborator Author

edsko commented Aug 9, 2024

If we want to support this at all, we probably only want to support it in a very minimal fashion, because libclang itself does not support this mode; so if for example we wanted to query libclang for the offsets of the fields inside structs, if there is CPP involved, we'd have to run libclang for each possible CPP permutation. Marking this as a low-priority enhancement for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority: low
Projects
None yet
Development

No branches or pull requests

1 participant