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

Fix return type of Bool for ccall methods #447

Merged
merged 7 commits into from
Nov 25, 2024
Merged

Fix return type of Bool for ccall methods #447

merged 7 commits into from
Nov 25, 2024

Conversation

odow
Copy link
Member

@odow odow commented Nov 25, 2024

No description provided.

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.78%. Comparing base (76ebea2) to head (583f001).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #447      +/-   ##
==========================================
+ Coverage   99.26%   99.78%   +0.52%     
==========================================
  Files           4        4              
  Lines         947      945       -2     
==========================================
+ Hits          940      943       +3     
+ Misses          7        2       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@odow odow changed the title Improve coverage of C_wrapper.jl Fix return type of Bool for ccall methods Nov 25, 2024
@@ -325,15 +301,12 @@ function AddIpoptNumOption(prob::IpoptProblem, keyword::String, value::Float64)
if !isascii(keyword)
error("IPOPT: Non ASCII parameters not supported")
end
ret = ccall(
(:AddIpoptNumOption, libipopt),
Cint,
Copy link
Member Author

Choose a reason for hiding this comment

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

A note to my future self when I come looking: the C API has bool as a return value. We don't have Cbool in Julia. But using Cint is dangerous because it sets only the 0/1 bit, leaving all others as random data.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, this has been around since the dawn of time:

Cint, (Ptr{Void}, Ptr{Uint8}, Ptr{Uint8}),

Back then it was a much simpler time, when dictionaries used the Python syntax:

Ipopt.jl/src/Ipopt.jl

Lines 50 to 69 in 323fb56

ApplicationReturnStatus = {
0=>:Solve_Succeeded,
1=>:Solved_To_Acceptable_Level,
2=>:Infeasible_Problem_Detected,
3=>:Search_Direction_Becomes_Too_Small,
4=>:Diverging_Iterates,
5=>:User_Requested_Stop,
6=>:Feasible_Point_Found,
-1=>:Maximum_Iterations_Exceeded,
-2=>:Restoration_Failed,
-3=>:Error_In_Step_Computation,
-4=>:Maximum_CpuTime_Exceeded,
-10=>:Not_Enough_Degrees_Of_Freedom,
-11=>:Invalid_Problem_Definition,
-12=>:Invalid_Option,
-13=>:Invalid_Number_Detected,
-100=>:Unrecoverable_Exception,
-101=>:NonIpopt_Exception_Thrown,
-102=>:Insufficient_Memory,
-199=>:Internal_Error}

@odow odow merged commit a9d6375 into master Nov 25, 2024
15 checks passed
@odow odow deleted the od/tests branch November 25, 2024 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant