-
Notifications
You must be signed in to change notification settings - Fork 57
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. 🚨 Try these New Features:
|
Bool
for ccall methods
@@ -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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
Line 202 in 323fb56
Cint, (Ptr{Void}, Ptr{Uint8}, Ptr{Uint8}), |
Back then it was a much simpler time, when dictionaries used the Python syntax:
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} |
No description provided.