From 29ca6a1d5bd2d334c5ce0a24a6f722a1b75299ed Mon Sep 17 00:00:00 2001 From: Tiezhen WANG Date: Fri, 17 Jan 2020 07:58:44 -0800 Subject: [PATCH] TFLM: Make main_functions C friendly. With extern "C", C++ compiler will skip naming mangling on these methods so that they can be called in C program, which many embedded developers use. PiperOrigin-RevId: 290270585 Change-Id: I2d302325e9c6bc3d16608a424767cfa44ea51816 --- .../lite/micro/examples/hello_world/main_functions.h | 9 +++++++++ .../lite/micro/examples/magic_wand/main_functions.h | 9 +++++++++ .../lite/micro/examples/micro_speech/main_functions.h | 9 +++++++++ .../micro/examples/person_detection/main_functions.h | 9 +++++++++ 4 files changed, 36 insertions(+) diff --git a/tensorflow/lite/micro/examples/hello_world/main_functions.h b/tensorflow/lite/micro/examples/hello_world/main_functions.h index e595cd87c8b..a1ea715c608 100644 --- a/tensorflow/lite/micro/examples/hello_world/main_functions.h +++ b/tensorflow/lite/micro/examples/hello_world/main_functions.h @@ -16,6 +16,11 @@ limitations under the License. #ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_HELLO_WORLD_MAIN_FUNCTIONS_H_ #define TENSORFLOW_LITE_MICRO_EXAMPLES_HELLO_WORLD_MAIN_FUNCTIONS_H_ +// Expose a C friendly interface for main functions. +#ifdef __cplusplus +extern "C" { +#endif + // Initializes all data needed for the example. The name is important, and needs // to be setup() for Arduino compatibility. void setup(); @@ -25,4 +30,8 @@ void setup(); // compatibility. void loop(); +#ifdef __cplusplus +} +#endif + #endif // TENSORFLOW_LITE_MICRO_EXAMPLES_HELLO_WORLD_MAIN_FUNCTIONS_H_ diff --git a/tensorflow/lite/micro/examples/magic_wand/main_functions.h b/tensorflow/lite/micro/examples/magic_wand/main_functions.h index 18671538c30..d69755b3a58 100644 --- a/tensorflow/lite/micro/examples/magic_wand/main_functions.h +++ b/tensorflow/lite/micro/examples/magic_wand/main_functions.h @@ -16,6 +16,11 @@ limitations under the License. #ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_MAGIC_WAND_MAIN_FUNCTIONS_H_ #define TENSORFLOW_LITE_MICRO_EXAMPLES_MAGIC_WAND_MAIN_FUNCTIONS_H_ +// Expose a C friendly interface for main functions. +#ifdef __cplusplus +extern "C" { +#endif + // Initializes all data needed for the example. The name is important, and needs // to be setup() for Arduino compatibility. void setup(); @@ -25,4 +30,8 @@ void setup(); // compatibility. void loop(); +#ifdef __cplusplus +} +#endif + #endif // TENSORFLOW_LITE_MICRO_EXAMPLES_MAGIC_WAND_MAIN_FUNCTIONS_H_ diff --git a/tensorflow/lite/micro/examples/micro_speech/main_functions.h b/tensorflow/lite/micro/examples/micro_speech/main_functions.h index 19599343652..0ac06771056 100644 --- a/tensorflow/lite/micro/examples/micro_speech/main_functions.h +++ b/tensorflow/lite/micro/examples/micro_speech/main_functions.h @@ -16,6 +16,11 @@ limitations under the License. #ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MAIN_FUNCTIONS_H_ #define TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MAIN_FUNCTIONS_H_ +// Expose a C friendly interface for main functions. +#ifdef __cplusplus +extern "C" { +#endif + // Initializes all data needed for the example. The name is important, and needs // to be setup() for Arduino compatibility. void setup(); @@ -25,4 +30,8 @@ void setup(); // compatibility. void loop(); +#ifdef __cplusplus +} +#endif + #endif // TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MAIN_FUNCTIONS_H_ diff --git a/tensorflow/lite/micro/examples/person_detection/main_functions.h b/tensorflow/lite/micro/examples/person_detection/main_functions.h index 2120ea92ddb..2620097a833 100644 --- a/tensorflow/lite/micro/examples/person_detection/main_functions.h +++ b/tensorflow/lite/micro/examples/person_detection/main_functions.h @@ -16,6 +16,11 @@ limitations under the License. #ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_PERSON_DETECTION_MAIN_FUNCTIONS_H_ #define TENSORFLOW_LITE_MICRO_EXAMPLES_PERSON_DETECTION_MAIN_FUNCTIONS_H_ +// Expose a C friendly interface for main functions. +#ifdef __cplusplus +extern "C" { +#endif + // Initializes all data needed for the example. The name is important, and needs // to be setup() for Arduino compatibility. void setup(); @@ -25,4 +30,8 @@ void setup(); // compatibility. void loop(); +#ifdef __cplusplus +} +#endif + #endif // TENSORFLOW_LITE_MICRO_EXAMPLES_PERSON_DETECTION_MAIN_FUNCTIONS_H_