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 A7C784366C; Mon, 4 Dec 2023 18:10:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3A7A9402AB; Mon, 4 Dec 2023 18:10:16 +0100 (CET) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mails.dpdk.org (Postfix) with ESMTP id B73AB400EF for ; Mon, 4 Dec 2023 18:10:15 +0100 (CET) Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1d03bcf27e9so19582755ad.0 for ; Mon, 04 Dec 2023 09:10:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1701709815; x=1702314615; darn=dpdk.org; 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=RkuWGQbAbgOYuh25gwpqXEdccMSLT56415MsPmpbnlE=; b=xx6cceVLIdBDY6ALEPkd2W6xuMPT/F1WNEF/y1q6QKMHD9x/QeORmDiz8ubLbaNKJO 5gu/XQruGghdSDEi/ozPWWF3tOfDIYYTclCFnQn/7bl4D0LgdwTWu91VINt3DfIBKv3G 6qKyg45RuCAaWektHqnVkr51UZPOI0X9dJSR7Lqs3p8Wfl5945hEd41MVWx9yH1z2+rJ RdoHTljk9Fet5BKPz/Be9JzMyvnE2J/WXtLvZgudoaaPXW5GoTlM8bn5xHyokEv/OLnd OIk7eDo5boGSpXklKaDCLt9+Z6vrR8vRGOfLFOswIQFot0ACzUFixaZLNIeY1IevT6Zj eSAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701709815; x=1702314615; 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=RkuWGQbAbgOYuh25gwpqXEdccMSLT56415MsPmpbnlE=; b=rBaXEAawtAh3Q8HDoihfsz2UKDY9XtMZbazlQ584h5XZqH70quDLMM7uwNAA4XvfHO wmzJx1DXfKbB9zGPeyditmS/xWEe1T8ADBnZzSxEfNSvj1YLGSJ54UMn+OJmg1POkuPb t/jZyVxLyHe2Wl882jO3df3WnC+kEVmV7uO1d+QINPJ4P8RL6/wQe4/oczrIggGV80KS 4pZU5/ULqUsHluxhD07RwPNuHcmqklePaKVT8uPNgHzCvwJeECWxqGrZumuvXcAMvo83 UHuDyaSksCZijeXF3nnJsCbyjJlme2G151kR3QlrkrOxVnQKhH5XLJxEfKdZTNU0v0ia Gw5Q== X-Gm-Message-State: AOJu0YxO3D7+vnH9Za3gYMLXar9RunWuXJ2Z10pnIuxrMhIHDxIVDfcO BHnkjc1QGUxijx/v8KEQgTFqlg== X-Google-Smtp-Source: AGHT+IEEpJeirb7nEWQtyno0sg8A3Vry121B2zlKaHxMi+Qlyn1UM+T6gzI8CaV9gv2GS7eR6WhNFg== X-Received: by 2002:a17:902:d508:b0:1cf:f28f:2d99 with SMTP id b8-20020a170902d50800b001cff28f2d99mr19318722plg.19.1701709814634; Mon, 04 Dec 2023 09:10:14 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id a1-20020a170902ecc100b001cfad601a4bsm8662273plh.10.2023.12.04.09.10.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 09:10:14 -0800 (PST) Date: Mon, 4 Dec 2023 09:10:12 -0800 From: Stephen Hemminger To: Chengwen Feng Cc: , , , Subject: Re: [RFC v2 1/6] argparse: add argparse library Message-ID: <20231204091012.7aa5046c@hermes.local> In-Reply-To: <20231204075048.894-2-fengchengwen@huawei.com> References: <20231121122651.7078-1-fengchengwen@huawei.com> <20231204075048.894-1-fengchengwen@huawei.com> <20231204075048.894-2-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Mon, 4 Dec 2023 07:50:43 +0000 Chengwen Feng wrote: > + static struct rte_argparse obj = { > + .prog_name = "test-demo", > + .usage = "[EAL options] -- [optional parameters] [positional parameters]", > + .descriptor = NULL, > + .epilog = NULL, > + .exit_on_error = true, > + .callback = argparse_user_callback, > + .args = { > + { "--aaa", "-a", "aaa argument", (void *)&aaa_val, (void *)100, RTE_ARGPARSE_ARG_NO_VALUE | RTE_ARGPARSE_ARG_VALUE_INT }, > + { "--bbb", "-b", "bbb argument", (void *)&bbb_val, NULL, RTE_ARGPARSE_ARG_REQUIRED_VALUE | RTE_ARGPARSE_ARG_VALUE_INT }, > + { "--ccc", "-c", "ccc argument", (void *)&ccc_val, (void *)200, RTE_ARGPARSE_ARG_OPTIONAL_VALUE | RTE_ARGPARSE_ARG_VALUE_INT }, > + { "--ddd", "-d", "ddd argument", NULL, (void *)1, RTE_ARGPARSE_ARG_NO_VALUE }, > + { "--eee", "-e", "eee argument", NULL, (void *)2, RTE_ARGPARSE_ARG_REQUIRED_VALUE }, > + { "--fff", "-f", "fff argument", NULL, (void *)3, RTE_ARGPARSE_ARG_OPTIONAL_VALUE }, > + { "ooo", NULL, "ooo argument", (void *)&ooo_val, NULL, RTE_ARGPARSE_ARG_REQUIRED_VALUE | RTE_ARGPARSE_ARG_VALUE_INT }, > + { "ppp", NULL, "ppp argument", NULL, (void *)300, RTE_ARGPARSE_ARG_REQUIRED_VALUE }, > + }, > + }; > + Could the API be made to work with immutable initializers? I.e allowing the application to use: static const struct rte_argparse_obj { Also better to just skip the NULL elements here, and use field initializers for the args. That way when structure layout changes, the example will still work. Also, pointers do not have to be cast to void * in C code.