diff --git a/paddle/fluid/pybind/bind_fleet_executor.h b/paddle/fluid/pybind/bind_fleet_executor.h index 733701fa36ba8..f9568819688e5 100644 --- a/paddle/fluid/pybind/bind_fleet_executor.h +++ b/paddle/fluid/pybind/bind_fleet_executor.h @@ -14,6 +14,10 @@ #pragma once +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#endif #include namespace paddle { diff --git a/paddle/fluid/pybind/compatible.h b/paddle/fluid/pybind/compatible.h index f9d4cf5888fee..5f7628e5f2ab9 100644 --- a/paddle/fluid/pybind/compatible.h +++ b/paddle/fluid/pybind/compatible.h @@ -14,6 +14,10 @@ #pragma once +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#endif #include namespace paddle { diff --git a/paddle/fluid/pybind/eager_functions.cc b/paddle/fluid/pybind/eager_functions.cc index 1073cdc83a428..4d7b50943d084 100644 --- a/paddle/fluid/pybind/eager_functions.cc +++ b/paddle/fluid/pybind/eager_functions.cc @@ -9,6 +9,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // disable numpy compile error + +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#endif + #include #include diff --git a/paddle/fluid/pybind/eager_method.cc b/paddle/fluid/pybind/eager_method.cc index 13fba2baa1d6c..e6bd1c0b52682 100644 --- a/paddle/fluid/pybind/eager_method.cc +++ b/paddle/fluid/pybind/eager_method.cc @@ -9,6 +9,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // disable numpy compile error + +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#endif + #include #include diff --git a/paddle/fluid/pybind/eager_utils.h b/paddle/fluid/pybind/eager_utils.h index 22c41073c9dd7..c4ddb34763228 100644 --- a/paddle/fluid/pybind/eager_utils.h +++ b/paddle/fluid/pybind/eager_utils.h @@ -10,6 +10,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #pragma once +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#endif + #include #include "paddle/phi/common/backend.h" #include "paddle/phi/common/data_type.h" diff --git a/paddle/fluid/pybind/inference_api.h b/paddle/fluid/pybind/inference_api.h index c2adfbecf72ca..300d3b480e113 100644 --- a/paddle/fluid/pybind/inference_api.h +++ b/paddle/fluid/pybind/inference_api.h @@ -14,6 +14,11 @@ #pragma once +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#endif + #include namespace paddle { diff --git a/paddle/fluid/pybind/io.h b/paddle/fluid/pybind/io.h index dfe3154cb95da..942c93deccf99 100644 --- a/paddle/fluid/pybind/io.h +++ b/paddle/fluid/pybind/io.h @@ -14,6 +14,11 @@ limitations under the License. */ #pragma once +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#endif + #include #include "paddle/fluid/pybind/pybind_boost_headers.h" diff --git a/paddle/fluid/pybind/op_function_common.h b/paddle/fluid/pybind/op_function_common.h index debaf8fae17b7..549da39d9b891 100644 --- a/paddle/fluid/pybind/op_function_common.h +++ b/paddle/fluid/pybind/op_function_common.h @@ -14,6 +14,11 @@ #pragma once +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#endif + #include #include #include diff --git a/paddle/fluid/pybind/protobuf.h b/paddle/fluid/pybind/protobuf.h index 4c5aa9701cd5a..54b788cccba5b 100644 --- a/paddle/fluid/pybind/protobuf.h +++ b/paddle/fluid/pybind/protobuf.h @@ -13,6 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #pragma once +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#endif #include #include diff --git a/python/paddle/fluid/tests/unittests/cc_imp_py_test.cc b/python/paddle/fluid/tests/unittests/cc_imp_py_test.cc index 8609aff1fa556..a0b9ec5f9f6d4 100644 --- a/python/paddle/fluid/tests/unittests/cc_imp_py_test.cc +++ b/python/paddle/fluid/tests/unittests/cc_imp_py_test.cc @@ -50,7 +50,8 @@ TEST(CC, IMPORT_PY) { // 3. C/C++ Run Python file std::string file_name(cwd); file_name.append("/test_install_check.py"); - FILE* fp = _Py_fopen(file_name.c_str(), "r+"); + PyObject* obj = Py_BuildValue("s", file_name.c_str()); + FILE* fp = _Py_fopen_obj(obj, "r+"); ASSERT_TRUE(fp != NULL); ASSERT_FALSE(PyRun_SimpleFile(fp, file_name.c_str()));