From mboxrd@z Thu Jan 1 00:00:00 1970 From: Phil Sutter Subject: Re: Does __attribute__((__packed__)) aplies to types or variables? Date: Sat, 24 Oct 2015 02:52:32 +0200 Message-ID: <20151024005130.8643C214AA@mail.nwl.cc> References: Mime-Version: 1.0 Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-c-programming-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: "Daniel." Cc: linux-c-programming@vger.kernel.org On Thu, Oct 22, 2015 at 02:18:47PM -0200, Daniel. wrote: > I mean that packed attribute is applied only when allocation is > implied or can I apply packed > attribute to struct definitions where no variables are declared? Yes, it applies to the type. > struct __attribute__((__packed__)) foo { ... }; > struct foo bar; <--- is this packed? Compare sizeof(struct foo) with sizeof(bar) to find out yourself. Cheers, Phil