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

configurator: regression in handling expressions for C imports #1720

Closed
avsm opened this issue Dec 29, 2018 · 1 comment
Closed

configurator: regression in handling expressions for C imports #1720

avsm opened this issue Dec 29, 2018 · 1 comment
Assignees

Comments

@avsm
Copy link
Member

avsm commented Dec 29, 2018

The fix for importing negative numbers in header files (#1334) added a dependency on the expression passed in also working with cpp. This prevents expressions such as sizeof(char) from being evaluated, as it leads to this error:

 | <...>/test.c:27:5: error: function-like macro 'sizeof' is not defined
 | #if sizeof(char) >= 0
 |     ^
 | 1 error generated.

I'm not sure what the best way to handle this is without knowing ahead of time if the value is possibly signed or not. We could distinguish C_define.Type to have a Uint that will not need the preprocess change above...

(This issue comes up when porting ctypes to dune)

avsm added a commit to avsm/dune that referenced this issue Dec 31, 2018
The current `C_define.Type.Int` supports signed integers since
the fix in ocaml#1344. This fix meant that some C expressions cannot
be evaluated such as `sizeof(expr)` since those are not valid
in cpp.

This changeset adds a new `Uint` type switch that is expressly
for the purpose of evaluating unsigned C integers only. This
allows for constructs such as `sizeof(expr)`.

This changeset lets the Ctypes library completely use Configurator
for all of its compile-time tests (yallop/ocaml-ctypes#574)

fixes ocaml#1720

Signed-off-by: Anil Madhavapeddy <anil@recoil.org>
@emillon emillon self-assigned this Jan 2, 2019
emillon added a commit to emillon/dune that referenced this issue Jan 2, 2019
emillon added a commit to emillon/dune that referenced this issue Jan 2, 2019
Rather than using the preprocessor to determine the sign of a value, we
store both `x` and `-x`. One of them has an all-digit representation.

Closes ocaml#1720

Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit to emillon/dune that referenced this issue Jan 2, 2019
Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit to emillon/dune that referenced this issue Jan 2, 2019
Rather than using the preprocessor to determine the sign of a value, we
store both `x` and `-x`. One of them has an all-digit representation.

Closes ocaml#1720

Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit to emillon/dune that referenced this issue Jan 2, 2019
Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit to emillon/dune that referenced this issue Jan 2, 2019
Rather than using the preprocessor to determine the sign of a value, we
store both `x` and `-x`. One of them has an all-digit representation.

Closes ocaml#1720

Signed-off-by: Etienne Millon <me@emillon.org>
@emillon
Copy link
Collaborator

emillon commented Jan 2, 2019

Closed by #1726

@emillon emillon closed this as completed Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants