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 320A7A0543 for ; Wed, 14 Dec 2022 09:03:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B5268400D6; Wed, 14 Dec 2022 09:03:52 +0100 (CET) Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by mails.dpdk.org (Postfix) with ESMTP id A11BA4003F for ; Wed, 14 Dec 2022 09:03:51 +0100 (CET) Received: by mail-ej1-f54.google.com with SMTP id n20so42626680ejh.0 for ; Wed, 14 Dec 2022 00:03:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=QlRycJcL/a6FPzBK1taddI5HbZVqlQya4FVlzu20Qro=; b=YqvRHjt6uw2lCls5px5q8d/uc4jCXtSpB90lrqwB/A5Qvk9ULyCHoJsiC2hhiAJ6Vz YAR3doKpWzcNj1eipufZicNUiEkH7rWSpwBjomN8MvKdhXmFSZ9lPfhpD1xp0bqCeA00 YBqDold2F3ouPybqMU0/lEG9M7wAQP1LUsrW2/Jpf9+22nIN24ajlp2S0e4fCuRbnyW1 FMVekJtsjAXQ1NmJxUFL0hZ6nka8yY/s/5eLiznaqo9pXN1PuBRbSJCE2P4bR9mOmLwa VsKD5EwpSuJMxZMA2BFTJ/Y2XsGc0FpEEfX64nidsFz41EqhuDu5nxKMHFIc+3ShzQeI x2Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QlRycJcL/a6FPzBK1taddI5HbZVqlQya4FVlzu20Qro=; b=uammUoNqekA9Uv8LKgsaym6UqFS6+t19YDrGmbju0evET7uPO7DcQvJDSXW/vMMt3z LtuO3JDmG4K5Xe9XdYJy194fzzA1RH29ZG5jjC3s1QU6q3x19HCBk7LyYhTuamWfMp3k MPbvUxEQUf3QW8N9gCl2aJpx3KQuP9DUi8c6JIWqPkZg+zet0btfWesxcHVB9msW/Avy vch30YVgHVMouNzB760zQJF9qXc73HvdaBnYfBD6DLS5FYFE7e2kqU9jWem4B0OMGMjw K0mVdbMHc6mzR6GZqDRciKsGfVL1BqdQmne5AbEcP30RKJ/WCAvZNt5yhg00SK9584Ig CIdA== X-Gm-Message-State: ANoB5pnZwqyyS87pR9Yg6OkhQ+NK9UHLdwNTE/TMUwKvpuR+QQoYUCyJ m6GW8PVnGMh6wEpRBuI3XpK1FlRGlG1me0fp+HY= X-Google-Smtp-Source: AA0mqf7oxdWX87iDLGdy7eGJqRfC8/iK8qTByLWMBlJ0mPq2mi6JJkNjosXOWywZkFcGBTnYcKWA7pk1FvhAeJ6QZn8= X-Received: by 2002:a17:907:76d6:b0:7c0:f7b0:9ad8 with SMTP id kf22-20020a17090776d600b007c0f7b09ad8mr14143588ejc.680.1671005031271; Wed, 14 Dec 2022 00:03:51 -0800 (PST) MIME-Version: 1.0 References: <20221213163447.14a96ea0@hermes.local> In-Reply-To: <20221213163447.14a96ea0@hermes.local> From: Antonio Di Bacco Date: Wed, 14 Dec 2022 09:03:40 +0100 Message-ID: Subject: Re: Anonymous structs in DPDK To: Stephen Hemminger Cc: Ferruh Yigit , users@dpdk.org Content-Type: text/plain; charset="UTF-8" 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 Hi, I need to completely isolate my application from DPDK, I'm building a C++ library that encapsulates the DPDK in order that the application doesn't need to include (either directly or indirectly) any DPDK header file. In the library cpp files I can include rte_spinlock.h but not in the .hpp files. Best regards. On Wed, Dec 14, 2022 at 1:34 AM Stephen Hemminger wrote: > > 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.