Skip to content

Commit 536deaa

Browse files
authored
Merge pull request #2309 from jsiirola/appsi-builder-msvc
APPSI: resolve build errors in MSVC
2 parents 5c8c824 + 2c5fdf7 commit 536deaa

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

CHANGELOG.txt

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ ADVANCE CHANGE NOTICE
6767
- APPSI: Correctly identify changes to constraints (#2299)
6868
- APPSI: Improvements to persistent interface (#2246)
6969
- APPSI: Implement FBBT in C++ module (#2248)
70+
- APPSI: Resolve build errors on Windows (#2309)
7071
- GDPopt: Fix bugs in preprocessing (#2211)
7172
- GDPopt: Switch preprocessing to use FBBT (#2264)
7273
- incidence_analysis: General improvements (#2239, #2240)

pyomo/contrib/appsi/build.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ def get_appsi_extension(in_setup=False, appsi_root=None):
4747
package_name = 'pyomo.contrib.appsi.cmodel.appsi_cmodel'
4848
else:
4949
package_name = 'appsi_cmodel'
50-
return Pybind11Extension(package_name, sources, extra_compile_args=['-std=c++11'])
50+
if sys.platform.startswith('win'):
51+
# Assume that builds on Windows will use MSVC
52+
# MSVC doesn't have a flag for c++11, use c++14
53+
extra_args = ['/std:c++14']
54+
else:
55+
# Assume all other platforms are GCC-like
56+
extra_args = ['-std=c++11']
57+
return Pybind11Extension(package_name, sources, extra_compile_args=extra_args)
5158

5259
def build_appsi(args=[]):
5360
print('\n\n**** Building APPSI ****')

pyomo/contrib/appsi/cmodel/src/interval.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ void _inverse_power1(double zl, double zu, double yl, double yu, double orig_xl,
489489
interval_exp(*xl, *xu, xl, xu);
490490

491491
// if y is an integer, then x can be negative
492-
if (yl == yu and yl == round(yl)) // y is a fixed integer
492+
if ((yl == yu) && (yl == round(yl))) // y is a fixed integer
493493
{
494494
int y = static_cast<int>(yl);
495495
if (y == 0) {
@@ -706,7 +706,7 @@ void interval_tan(double xl, double xu, double *res_lb, double *res_ub) {
706706
// minimum value of i such that pi*i + pi/2 >= xl. Then round i up. If pi*i +
707707
// pi/2 is still less than or equal to xu, then there is an undefined point
708708
// between xl and xu.
709-
if (xl <= -inf or xu >= inf) {
709+
if ((xl <= -inf) || (xu >= inf)) {
710710
*res_lb = -inf;
711711
*res_ub = inf;
712712
} else if (_is_inf(xl) || _is_inf(xu))

0 commit comments

Comments
 (0)