From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A8ADEA0543 for ; Wed, 14 Dec 2022 01:34:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 31B874021D; Wed, 14 Dec 2022 01:34:52 +0100 (CET) Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by mails.dpdk.org (Postfix) with ESMTP id E190D4003F for ; Wed, 14 Dec 2022 01:34:50 +0100 (CET) Received: by mail-pf1-f178.google.com with SMTP id w26so3376598pfj.6 for ; Tue, 13 Dec 2022 16:34:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=uQRTHcjuON0ltGc1CQbHC6e2eulpw6cUM5JwXVCeYgg=; b=UDd5WxzGrwnNGO3B+HasluIQduMzpejPKhEiDC0pkXwr4eixF7G4nC192fZyl/Il0w gGjCCdg1OCyszZPyTja8baE2S6hiItS/CN0uiEpqCf9hqF0/9QHqb11QnFlvrmcDqKBp tFhYEsmw2bhaAJa5awlGY3es36DhXVTfvLgRMp8vel15JMYiYDmy7GYBJE67Dz/DNER7 928gqDS7b8W4GDwfcHuo8K8OnzkRFr2OY6PRpXQM97sMFmvuVQspM7Ws6sNGsF3q+kmX SaH3TQSVlmPSZLNaWtBYu0JQ1s+Uy6MinFfIOg4MSRXApagYM3Qxe1zMdLH6KgGwztPn tmVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uQRTHcjuON0ltGc1CQbHC6e2eulpw6cUM5JwXVCeYgg=; b=ZxUj/kYroQFZW2wNbgXWHIqptxG6Spbnngd6eMFIwE3ac43uWvgTrJP4JzZ/wLL6lX AipKbAfiY03VaYm4Dz4FP1kO+H6iG+NG7BKqID7PXqBEwpPGwP3K83Zw8aKZB+ZHPutX 8YV0HaLSngY3h3kV6QQmB7AOXCh9rbciaHHNKHnB9/5NJZf+Bf5R/IovtNmMbrKwHLWb GVgrbUtKmsNRpth4DAuH4uKSjqHeXWfKm1jUn/kwjn6O7lto0YQ3H1iCkdn17tsCGZBQ bCUEtYOzhkFmthWHqDngX+KG1VdxlxxdUmgwLe3yRjG9xADaL10r6qN4BvrdewsTAI0L XPEw== X-Gm-Message-State: ANoB5plMOmcQc3wQb3FhUcBU6mEOnKG7u/xfpIxhT0laMCsTMMmD8YyR PnRkj+uvmi2Vs5WuG+bN5/yRjg== X-Google-Smtp-Source: AA0mqf65/P2hZR6tGvXELOoW9AdtnPJXAMu5sNZeMWHuOASS+6J5dvK6TtMCIhvwMWoaSEtcG2JVUg== X-Received: by 2002:a62:148f:0:b0:566:900e:1040 with SMTP id 137-20020a62148f000000b00566900e1040mr21273546pfu.32.1670978089830; Tue, 13 Dec 2022 16:34:49 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id d20-20020a621d14000000b005771475561bsm8179237pfd.163.2022.12.13.16.34.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 16:34:49 -0800 (PST) Date: Tue, 13 Dec 2022 16:34:47 -0800 From: Stephen Hemminger To: Ferruh Yigit Cc: Antonio Di Bacco , users@dpdk.org Subject: Re: Anonymous structs in DPDK Message-ID: <20221213163447.14a96ea0@hermes.local> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: users-bounces@dpdk.org On Tue, 13 Dec 2022 13:55:10 +0000 Ferruh Yigit wrote: > On 12/13/2022 12:51 PM, Antonio Di Bacco wrote: > > I noticed that DPDK include files have a number of anonymous/unnamed struct: > > > > For example: > > > > /** > > * The rte_spinlock_t type. > > */ > > typedef struct { > > volatile int locked; /**< lock status 0 = unlocked, 1 = locked */ > > } rte_spinlock_t; > > > > This choice doesn't allow to use forward declaration. I need forward > > declaration because I'm using a rte_spinlock_t pointer in a C++ class > > and I don't want to include rte_spinlock.h to prevent my application > > to include it as well. > > > > Is there any reason to use unnamed structures? > > > > Hi Antonio Di, > > I don't think there is a specific reason to not use named struct, I > assume that is only because there was no need to have it. > > So if you need, you can send a simple patch to convert anonymous struct > to named struct, although I am not clear why you can't include > 'rte_spinlock.h' in the file you declare your class. > > Cheers, > ferruh Why not include rte_spinlock.h? Spinlocks are meant to be embedded in the object using it. Using spinlocks by reference adds more space and causes a cache miss.