diff --git a/paddle/fluid/pybind/bind_fleet_executor.h b/paddle/fluid/pybind/bind_fleet_executor.h index 733701fa36ba852d4b499640a3698c023aaae3b3..f9568819688e58b8e1c270a1d127f9a60a170d10 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 f9d4cf5888fee8f62ce2e64636da6b98542b1a75..5f7628e5f2ab9b3eb4f1f6163599b31a033ad7e2 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 1073cdc83a428bd0a4159b2202e0e21dd84dedd2..4d7b50943d0840850f983a446228c8e8ce41c293 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 7620be96c10329acf8c4dab68c26b4b7d15730b6..000928e0e0e04fe64439593cc53788cf13e74622 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 1e9cf705ace1d604ea067320d7581019d1ef5282..f1fab6db6ead185316efa36ffa774299d82eb901 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 c2adfbecf72ca0f475e526ca97adf9833b03ede4..300d3b480e1130a6315d9d883d69e4fa9da44e41 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 dfe3154cb95da529536c0022fc82169d476f3913..942c93deccf99f0913909b66766927046b1e5809 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 debaf8fae17b7caa3137852d2f5156349bae704e..549da39d9b891b6d08cc668c1eadc7530486ed81 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 4c5aa9701cd5a17ab33ce9bc5c5f61ac11207b80..54b788cccba5b161bc54b65be16422db8a25e916 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 8609aff1fa55632d0f757aecc355a4eab83e1d1f..a0b9ec5f9f6d465d767f7071eaaf121e7d17f955 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()));