From 9af6ffc202a18bc40d1014c6e43f21a533909277 Mon Sep 17 00:00:00 2001 From: Alexander Lyashuk Date: Fri, 13 Sep 2024 09:23:00 -0700 Subject: [PATCH] [PJRT] Use `typedef struct X {} X;` idiom for PJRT_Api. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows forward declaration (`struct PJRT_Api;`) in C++, i.e. if you want to carry `PJRT_Api` as an opaque pointer to pass further without need to depend on the actual header. In C, `struct X` and (typedef) `X` are in different namespaces so they can coexist. In C++ this idiom is allowed by ยง 9.2.3.3 of the standard for compatibility with C. PiperOrigin-RevId: 674324680 --- xla/pjrt/c/pjrt_c_api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xla/pjrt/c/pjrt_c_api.h b/xla/pjrt/c/pjrt_c_api.h index 96b71755b60e8..1d5b44c60201c 100644 --- a/xla/pjrt/c/pjrt_c_api.h +++ b/xla/pjrt/c/pjrt_c_api.h @@ -2118,7 +2118,7 @@ typedef PJRT_Error* PJRT_Compile(PJRT_Compile_Args* args); #define _PJRT_API_STRUCT_FIELD(fn_type) fn_type* fn_type // Please modify PJRT_Api_STRUCT_SIZE if the last field of PJRT_Api is changed. -typedef struct { +typedef struct PJRT_Api { size_t struct_size; PJRT_Extension_Base* extension_start;