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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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: Sat May 04 12:01:31 2024 UTC