php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #75491 need structs, unions
Submitted: 2017-11-06 21:18 UTC Modified: 2018-11-23 17:41 UTC
From: jmichae35 at gmail dot com Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 7.2.0RC5 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jmichae35 at gmail dot com
New email:
PHP Version: OS:

 

 [2017-11-06 21:18 UTC] jmichae35 at gmail dot com
Description:
------------
need structs and unions like in C/C++. an anon class comes close, but is not quite it. and it needs to have byte alignment.

Expected result:
----------------
struct {
...
}
...
union {
...
}
if you can obtain it from ANSI spec


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-11-06 22:08 UTC] pollita@php.net
-Status: Open +Status: Wont fix
 [2017-11-06 22:08 UTC] pollita@php.net
You're never going to find something like this in PHP because of the way PHP's memory layout works.
 [2017-11-06 22:49 UTC] jmichae35 at gmail dot com
you might try implementing some particularly useful ones like windows' SYSTEM_TIME and struct time_t.
 [2018-11-21 02:24 UTC] a at b dot c dot de
An anon class comes close, but associative arrays come closer.

time_t is not a struct, it's an arithmetic type with semantics that are explicitly undefined by the standard. The value returned by PHP's time() function would be acceptable.

You're thinking of the tm struct, which is specified as having at least (possibly more) a certain list of fields that are all defined as integers. The only thing missing from the array returned by getdate() is the isDST field.

Byte alignment is a meaningless requirement for a PHP application.
 [2018-11-23 17:41 UTC] jmichae35 at gmail dot com
byte alignment eliminates gaps between structures in the array when it doesn't come up to 16 bytes (usual default).
so byte alignment would take less memory overall.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 01:01:30 2024 UTC