<div dir="ltr">I could be wrong, but I think __maybe_unused is an old way to spell [[maybe_unused]] which is documented here: <a href="https://eel.is/c++draft/dcl.attr.unused">https://eel.is/c++draft/dcl.attr.unused</a><div><br></div><div>In short it indicates that an entity might be intentionally unused, so it suppresses a warning that something might be accidentally unused.  It should have no semantic effect (such as an impact on layout).</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 5, 2021 at 3:23 PM Vincent Li via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I could be not making  sense here since I am newbie to compiler and<br>
not even sure if this is a problem that compiler should care to<br>
address<br>
<br>
I ran into this<br>
<a href="https://github.com/cilium/cilium/pull/17370#discussion_r731170618" rel="noreferrer" target="_blank">https://github.com/cilium/cilium/pull/17370#discussion_r731170618</a><br>
<br>
where the suggestion to add conditional field like below,<br>
<br>
<br>
 struct remote_endpoint_info {<br>
        __u32           sec_label;<br>
        __u32           tunnel_endpoint;<br>
#ifdef ENABLE_VTEP<br>
        mac_t           vtep_mac;<br>
#endif<br>
        __u8            key;<br>
 };<br>
<br>
but it cause misalignment issue with golang struct below:<br>
<br>
// RemoteEndpointInfo implements the bpf.MapValue interface. It contains the<br>
// security identity of a remote endpoint.<br>
// +k8s:deepcopy-gen=true<br>
   +k8s:deepcopy-gen:interfaces=<a href="http://github.com/cilium/cilium/pkg/bpf.MapValue" rel="noreferrer" target="_blank">github.com/cilium/cilium/pkg/bpf.MapValue</a><br>
type RemoteEndpointInfo struct {<br>
        SecurityIdentity uint32        `align:"sec_label"`<br>
        TunnelEndpoint   types.IPv4    `align:"tunnel_endpoint"`<br>
        VtepMAC          mac.Uint64MAC `align:"vtep_mac"`<br>
        Key              uint8         `align:"key"`<br>
}<br>
<br>
so out of my imagination without understanding things going on<br>
underneath, I attempted to use __maybe_unused since I saw it being<br>
used for stack variable,<br>
<br>
 struct remote_endpoint_info {<br>
        __u32           sec_label;<br>
        __u32           tunnel_endpoint;<br>
       mac_t           vtep_mac __maybe_unused;<br>
        __u8            key;<br>
 };<br>
<br>
the clang llvm did not complain error, but it has no effect on the<br>
struct memory layout neither, so I wonder if __maybe_unused to struct<br>
field is a thing, or if I am looking for wrong solution for the<br>
problem, appreciate any input<br>
<br>
Thanks<br>
<br>
Vincent<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>