Skip to content

Zend/zend_types.h: deprecate zend_bool, zend_intptr_t, zend_uintptr_t #10597

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

Merged
merged 1 commit into from
Feb 18, 2023

Conversation

MaxKellermann
Copy link
Contributor

These types are standard C99. For compatibility with out-of-tree extensions, keep the typedefs in main/php.h.

@@ -47,7 +47,6 @@
# define ZEND_ENDIAN_LOHI_C_4(a, b, c, d) a, b, c, d
#endif

typedef bool zend_bool;
typedef unsigned char zend_uchar;
Copy link
Contributor

Choose a reason for hiding this comment

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

should be probably deprecated as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand zend_bool, zend_*inptr_t were definitions from a time when C99 wasn't required; but unsigned char has always been available, everywhere. Therefore I figured this is not a compatibility definition, but .... I don't know. This doesn't make any sense to me, but I suggested deprecating only those I understood.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apparently, zend_uchar isn't used as an unsigned char ("char" as in "ASCII character" - the C nomenclature is confusing), but as small unsigned integer. This is confusing. I'd recommend using uint_least8_t everywhere instead, to clearly indicate that this is about small integers and not ASCII characters.

@@ -434,4 +434,10 @@ END_EXTERN_C()

#include "php_reentrancy.h"

/* the following typedefs are deprecated; use the standard C99 types
* instead */
typedef bool zend_bool;
Copy link
Contributor

Choose a reason for hiding this comment

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

if used, they should emit a compiler warning, also I would add something like "and will be removed in PHP 9.0"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added ZEND_ATTRIBUTE_DEPRECATED, but there appears to be no way to attach a message to this GCC attribute.

Copy link
Contributor

Choose a reason for hiding this comment

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

GCC should warn implicitly when -Wno-deprecated-declarations is not passed

php-src CI should not pass if any GCC warning is produced

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but I thought you meant that GCC should write "will be removed in 9" in the message. In C++, the deprecated attribute can be annotated with a message that is printed (https://en.cppreference.com/w/cpp/language/attributes/deprecated), but not the proprietary GCC attribute.
Will add the 9.0 comment.

@MaxKellermann MaxKellermann force-pushed the intptr branch 2 times, most recently from 034cb2e to 3544ec4 Compare February 15, 2023 13:17
These types are standard C99.  For compatibility with out-of-tree
extensions, keep the typedefs in main/php.h.
@MaxKellermann
Copy link
Contributor Author

AppVeyor failure because ZEND_ATTRIBUTE_DEPRECATED doesn't work with typedefs on Windows (MSVC).
I removed the attribute for now; maybe we need a typedef-specific macro for the deprecated attribute that's empty on MSVC?

@mvorisek
Copy link
Contributor

AppVeyor failure because ZEND_ATTRIBUTE_DEPRECATED doesn't work with typedefs on Windows (MSVC). I removed the attribute for now; maybe we need a typedef-specific macro for the deprecated attribute that's empty on MSVC?

https://stackoverflow.com/questions/4995868/deprecate-typedef

@MaxKellermann
Copy link
Contributor Author

Oh hooray, GCC wants the attribute at the end after the name, and MSVC wants it between typedef and the type.

@Girgias Girgias merged commit 413844d into php:master Feb 18, 2023
simpletoimplement added a commit to simpletoimplement/igbinary-igbinary that referenced this pull request Feb 18, 2023
@MaxKellermann MaxKellermann deleted the intptr branch February 21, 2023 15:32
crrodriguez pushed a commit to crrodriguez/php-src that referenced this pull request Feb 21, 2023
…php#10597)

These types are standard C99.

For compatibility with out-of-tree extensions, keep the typedefs
in main/php.h.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants