From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-2.sys.kth.se (smtp-2.sys.kth.se [130.237.32.160]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id q58C63kg010846 for ; Fri, 8 Jun 2012 08:06:03 -0400 (EDT) Received: from mailscan-1.sys.kth.se (mailscan-1.sys.kth.se [130.237.32.91]) by smtp-2.sys.kth.se (Postfix) with ESMTP id 8460114FAD5; Fri, 8 Jun 2012 14:05:57 +0200 (CEST) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-2.sys.kth.se ([130.237.32.160]) by mailscan-1.sys.kth.se (mailscan-1.sys.kth.se [130.237.32.91]) (amavisd-new, port 10024) with LMTP id ZlxJX0wGLBG1; Fri, 8 Jun 2012 14:05:56 +0200 (CEST) X-KTH-Auth: kristaps [193.10.49.5] X-KTH-mail-from: kristaps@bsd.lv Received: from ctime.hhs.se (ctime.hhs.se [193.10.49.5]) by smtp-2.sys.kth.se (Postfix) with ESMTP id B714F14FA53; Fri, 8 Jun 2012 14:05:55 +0200 (CEST) Message-ID: <4FD1EAA3.7060306@bsd.lv> Date: Fri, 08 Jun 2012 14:05:55 +0200 From: Kristaps Dzonsons User-Agent: Mozilla/5.0 (X11; OpenBSD amd64; rv:5.0) Gecko/20110805 Thunderbird/5.0 X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 To: espie@nerim.net CC: tech@mdocml.bsd.lv Subject: Re: mandocdb tools, sqlite3, and ohash References: <4FD0C58C.5040104@bsd.lv> <20120607165106.GA8819@lain.home> In-Reply-To: <20120607165106.GA8819@lain.home> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 06/07/12 18:51, Marc Espie wrote: > On Thu, Jun 07, 2012 at 05:15:24PM +0200, Kristaps Dzonsons wrote: >> struct str { >> ...stuff here... >> char key[1]; >> }; >> >> ...with allocation in the regular way (the struct size plus the >> string length). Is this known to play nicely with all compilers? I >> can't think of a better way without modifying the ohash routines to >> work with key pointers. > > Yes, it will "work". > All old compilers I know will accept it, > and it has been formally normalized in C99, with a slightly different > syntax. > > Refer to 6.7.2.1 16 > It talks about flexible array members. > > For C99, the syntax should be > > struct str { > ... > char key[]; > }; > > and obviously, the length is smaller by one. > > as far as I know, all compilers do still accept the former syntax and will > work just fine on all architectures that matter. Marc, Thanks for the note. I'll use the C99 approach and will add the necessary bits if people complain. Best, Kristaps -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv