Skip to content

Commit

Permalink
[PJRT] Use typedef struct X {} X; idiom for PJRT_Api.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mooskagh authored and Google-ML-Automation committed Sep 13, 2024
1 parent ec176ba commit 9af6ffc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion xla/pjrt/c/pjrt_c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 9af6ffc

Please sign in to comment.