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

[c_api] Improve ANSI compatibility by avoiding <stdbool.h> #4697

Merged
merged 6 commits into from
Nov 15, 2021
Merged

[c_api] Improve ANSI compatibility by avoiding <stdbool.h> #4697

merged 6 commits into from
Nov 15, 2021

Conversation

drewmiller
Copy link
Contributor

Mentioned in #4609, these edits improve ANSI C compatibility by removing reliance on stdbool.h. These edits may cause a compiler warning for existing code which passes a _Bool pointer as out. However, given the brief tenure of ANSI C compatibility, it seems unlikely there will be much breakage.

.ci/test.sh Outdated Show resolved Hide resolved
include/LightGBM/c_api.h Outdated Show resolved Hide resolved
Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks a lot for your contribution!

@shiyu1994
Copy link
Collaborator

Shall we change the call of LGBM_BoosterGetLinear in basic.py?

out_is_linear = ctypes.c_bool(False)
_safe_call(_LIB.LGBM_BoosterGetLinear(
self.handle,
ctypes.byref(out_is_linear)))

Since _Bool may have smaller size than int, it seems that we can wrongly set some unallocated bytes when calling LGBM_BoosterGetLinear.

Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we change the call of LGBM_BoosterGetLinear in basic.py?

Ah, indeed, we definitely should! Sorry, I missed this one call of LGBM_BoosterGetLinear across the whole LightGBM codebase.

@drewmiller Could you please update the linked Python code or do you need any help with it?

@StrikerRUS
Copy link
Collaborator

Kindly ping @drewmiller

@drewmiller
Copy link
Contributor Author

Kindly ping @drewmiller

Apologies for the delay. Will make the change this weekend.

@StrikerRUS
Copy link
Collaborator

No problem, please take your time. I just wanted to make sure you didn't forget about this PR.

@StrikerRUS StrikerRUS requested review from shiyu1994 and removed request for shiyu1994 November 14, 2021 00:52
Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @drewmiller !

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants