Skip to content

Commit ef7fe65

Browse files
jameslovespancakescopybara-github
authored andcommitted
PR #102674: Fix TensorFlow Lite build error with Android NDK (#102572)
Imported from GitHub PR tensorflow/tensorflow#102674 Fix TensorFlow Lite build error with Android NDK (tensorflow/tensorflow#102572) Guard sys/types.h include to prevent build failures on Windows and certain Android NDK configurations. The file_util.h header unconditionally included <sys/types.h>, which is not available or doesn't properly define off_t on Windows. Since the code already handles Windows separately by using __int64 for the Offset type alias instead of off_t, the sys/types.h include is only needed on POSIX systems. This fix adds a platform guard to only include sys/types.h on non-Windows platforms, preventing compilation errors when building TensorFlow Lite for Android with CMake and Android NDK. Fixes tensorflow/tensorflow#102572 Copybara import of the project: -- ef974d25fa30a0b21fbb09f34a58a8f95dc3a69e by jameslovespancakes <jmlenhard@wm.edu>: Fix TensorFlow Lite build error with Android NDK (#102572) Guard sys/types.h include to prevent build failures on Windows and certain Android NDK configurations. The file_util.h header unconditionally included <sys/types.h>, which is not available or doesn't properly define off_t on Windows. Since the code already handles Windows separately by using __int64 for the Offset type alias instead of off_t, the sys/types.h include is only needed on POSIX systems. This fix adds a platform guard to only include sys/types.h on non-Windows platforms, preventing compilation errors when building TensorFlow Lite for Android with CMake and Android NDK. Fixes #102572 Merging this change closes #102674 FUTURE_COPYBARA_INTEGRATE_REVIEW=tensorflow/tensorflow#102674 from jameslovespancakes:fix-tflite-android-ndk-build ef974d25fa30a0b21fbb09f34a58a8f95dc3a69e PiperOrigin-RevId: 822651695
1 parent 662cdbf commit ef7fe65

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tflite/delegates/xnnpack/file_util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ limitations under the License.
1515
#ifndef TENSORFLOW_LITE_DELEGATES_XNNPACK_FILE_UTIL_H_
1616
#define TENSORFLOW_LITE_DELEGATES_XNNPACK_FILE_UTIL_H_
1717

18+
#if !defined(_WIN32)
1819
#include <sys/types.h>
20+
#endif
1921

2022
#include <cstddef>
2123
#include <utility>

0 commit comments

Comments
 (0)