public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "levi.yun" <yeoreum.yun@arm.com>
To: "Kinney, Michael D" <michael.d.kinney@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: nd <nd@arm.com>, Sami Mujawar <Sami.Mujawar@arm.com>
Subject: Re: [edk2-devel] [Question] using Flexible Array Member in Structure.
Date: Fri, 5 Apr 2024 06:43:07 +0000	[thread overview]
Message-ID: <AM0PR08MB4289DDCE0B3C16B47742E11EFB032@AM0PR08MB4289.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <CO1PR11MB4929D791E16DFF6733AE5B1ED23D2@CO1PR11MB4929.namprd11.prod.outlook.com>

Hi Michael! Thanks for answer.

> Converting these to a flexible array member would not be
a backwards compatible change.

That's the point. But at least when I see the compiler used in tool_def.txt,
there's no compiler which doesn't support to flexible array member.

Do we still need to consider the case building edk2 with lower version of comipler
which isn't manifested in tool_def.txt?

Thanks!


________________________________________
From: Kinney, Michael D <michael.d.kinney@intel.com>
Sent: 03 April 2024 17:17
To: devel@edk2.groups.io; Yeo Reum Yun
Cc: nd; Sami Mujawar; Kinney, Michael D
Subject: RE: [edk2-devel] [Question] using Flexible Array Member in Structure.

Yes.  Use of flexible array members is supported and encouraged.

There are challenges with existing structure definitions that declare
arrays of size [1] when a flexible array is really intended. Those
were defined before flexible array members were supported by all the
compilers.  Converting these to a flexible array member would not be
a backwards compatible change.

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
> levi.yun
> Sent: Wednesday, April 3, 2024 2:27 AM
> To: devel@edk2.groups.io
> Cc: nd@arm.com; sami.mujawar@arm.com
> Subject: [edk2-devel] [Question] using Flexible Array Member in
> Structure.
>
> Hello all!
>
> while I see the code. I have one question related using Flexible Array
> Member.
>
> For example)
>
> ///
> /// Socket Type Data.
> ///
> typedef struct {
>    EFI_ACPI_6_4_PMTT_COMMON_MEMORY_DEVICE CommonMemoryDeviceHeader;
>    UINT16 SocketIdentifier;
>    UINT16 Reserved;
>    // EFI_ACPI_6_4_PMTT_COMMON_MEMORY_DEVICE MemoryDeviceStructure[];
> } EFI_ACPI_6_4_PMTT_SOCKET_TYPE_DATA;
>
> In here, why MemoryDeviceStructure should remain with comments?
>
> IIUC, edk2 coding style guide doesn't seem to prevent use of Flexible
> Array Member which is C99 standard.
>
> And consider the compiler used to compile edk2 uses defaults standard
> above of C99 standard.
>
> Couldn't I use the flexible array member like:
>
> ///
> /// Socket Type Data.
> ///
> typedef struct {
>    EFI_ACPI_6_4_PMTT_COMMON_MEMORY_DEVICE CommonMemoryDeviceHeader;
>    UINT16 SocketIdentifier;
>    UINT16 Reserved;
>    EFI_ACPI_6_4_PMTT_COMMON_MEMORY_DEVICE  MemoryDeviceStructure[]
> }
>
> Thanks!
>
>
> 
>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117453): https://edk2.groups.io/g/devel/message/117453
Mute This Topic: https://groups.io/mt/105305209/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2024-04-05  6:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-03  9:27 [edk2-devel] [Question] using Flexible Array Member in Structure levi.yun
2024-04-03 16:17 ` Michael D Kinney
2024-04-05  6:43   ` levi.yun [this message]
2024-04-05  7:29     ` Pedro Falcato
2024-04-05  7:34 ` Pedro Falcato

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM0PR08MB4289DDCE0B3C16B47742E11EFB032@AM0PR08MB4289.eurprd08.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox