PSOPT / psopt

PSOPT Optimal Control Software
GNU Lesser General Public License v2.1
193 stars 75 forks source link

psopt.h defines variable inf, which interferes with other libraries #38

Closed schulz0r closed 3 years ago

schulz0r commented 3 years ago

Hello, As the title says, psopt.h defines a variable which is a class in the geometry library CGAL. That's why programs which make use of both dependencies cannot compile. I suggest that you use std::numeric_limits<T>::infinity from the header limits so that you don't need to define your own infinity. Edit: Since there are no tests, I cannot simply commit the proposed solution. After all, I am changing a variable. I still need to fix this issue as soon as possible, so I will go the safe route and put inf into a namespace and fix all compile errors. I guess this won't break anything.

Best regards

Philipp

vmbecerra commented 3 years ago

Hello Phillip

I liked your idea of creating a PSOPT namespace. I have added pi to the namespace as well. The namespace needs to be included by the user if the double constants inf and pi are to be used just like that. Otherwise, the user will need to employ PSOPT::inf and PSOPT::pi. I have also defined the value of inf using the std:numeric_limitinfinity that you suggested. To avoid clashes with libraries that use inf, then it is a matter of not including the PSOPT namespace in the user code.