From owner-freebsd-net@FreeBSD.ORG Tue Jul 26 07:14:10 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 65B04106564A for ; Tue, 26 Jul 2011 07:14:10 +0000 (UTC) (envelope-from vladimir.budnev@gmail.com) Received: from mail-ew0-f54.google.com (mail-ew0-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id EE7208FC08 for ; Tue, 26 Jul 2011 07:14:09 +0000 (UTC) Received: by ewy1 with SMTP id 1so184835ewy.13 for ; Tue, 26 Jul 2011 00:14:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=qW2XuDPy0c7JeiZRaATvk7V7MBwNDWZD03ZyI6ro6gE=; b=mtHdeAElg0Pw7/O65i8thbJjVJJtGEy9rgBxjtRCB3UholsCQSehXQLSDlhytkOogR zyzl0NldZgZUMOl5EpPM7RAG/KdOhaAwN/mHXTdWTJ10tqpT0Obrj9gLar8WBS5p5EMr t7D0Yt2YTK3KbVkOHrvMocvhM/HO+7sA7KZEg= Received: by 10.204.13.202 with SMTP id d10mr557913bka.123.1311664448679; Tue, 26 Jul 2011 00:14:08 -0700 (PDT) Received: from [192.168.66.106] ([80.253.27.98]) by mx.google.com with ESMTPS id l21sm64424bkt.35.2011.07.26.00.14.07 (version=SSLv3 cipher=OTHER); Tue, 26 Jul 2011 00:14:07 -0700 (PDT) Message-ID: <4E2E692E.6050503@gmail.com> Date: Tue, 26 Jul 2011 11:13:50 +0400 From: Vladimir Budnev User-Agent: Mozilla/5.0 (X11; U; Linux i686; ru_RU; rv:1.9.1.16) Gecko/20110303 Icedove/3.0.11 MIME-Version: 1.0 To: Bruce Evans References: <20110723100828.S4156@besplex.bde.org> In-Reply-To: <20110723100828.S4156@besplex.bde.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-net@FreeBSD.org Subject: Re: What does define COMMENT_ONLY mean? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jul 2011 07:14:10 -0000 On 07/23/11 04:21, Bruce Evans wrote: > > C didn't support support variable-sized structs before C99, and > doesn't really support them now. Various hacks are used to make > pseudo-structs larger or smaller than ones that can actually be > declared work. The above is one. The pseudo-struct is malloc()ed > and has size larger than the declared one. The above says what > would be in it if it could be declared. > > If this were written in C99, it might declare u_char ar_foo[] in the > the code instead of in a comment. But C can't really support variable- > sized structs. It only allows one ar_foo[], which must be at the end > of the struct. ar_foo then has a known offset but an unknown size. > The other ar_bar[]'s still can't be declared, since they want to be > further beyond the end of the struct, which places them at an unknown > offset. > > A probably-less-unportable way was to declare everything in the struct > but malloc() less. This only works if all the magic fields are at > known offsets. This doesn't work in the above, since the fields want > to have variable lengths each and thus end up at variable offsets. > Such fields can be allocated from a single larger field (usually an > an array), but you lose the possibility of declaring them all. > > Bruce I got the idea with "dynamic size", tnx:) But comment_only ...ah nevermined. Tnx for explanation, Bruce.