Skip to content

Avoid C99 typedef redeclaration error #15079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
16 changes: 9 additions & 7 deletions Zend/zend_property_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,21 @@

BEGIN_EXTERN_C()

typedef struct _zend_array zend_array;
typedef struct _zend_class_entry zend_class_entry;
typedef struct _zend_object zend_object;
typedef struct _zend_object_iterator zend_object_iterator;
typedef struct _zval_struct zval;
/* Intentionally avoid typedef because of C99 redeclaration errors. */
struct _zend_array;
Copy link
Member

@TimWolla TimWolla Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing this, I already wondered before: Why is the struct tag even prefixed with an underscore instead of matching the typedef'd name exactly?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is just an convention to avoid having identical names. And maybe also as a hint that clients should use the typedef'd name.

struct _zend_class_entry;
struct _zend_object;
struct _zend_object_iterator;
struct _zval_struct;

typedef enum {
ZEND_PROPERTY_HOOK_GET = 0,
ZEND_PROPERTY_HOOK_SET = 1,
} zend_property_hook_kind;

ZEND_API zend_object_iterator *zend_hooked_object_get_iterator(zend_class_entry *ce, zval *object, int by_ref);
ZEND_API zend_array *zend_hooked_object_build_properties(zend_object *zobj);
ZEND_API struct _zend_object_iterator *zend_hooked_object_get_iterator(
struct _zend_class_entry *ce, struct _zval_struct *object, int by_ref);
ZEND_API struct _zend_array *zend_hooked_object_build_properties(struct _zend_object *zobj);

END_EXTERN_C()

Expand Down
Loading