From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 5B8207803D8 for ; Mon, 21 Oct 2024 20:26:12 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=qMlt+FSjhGfeAMAeVkollp7pLgHgx+s4Rb71s2ccTOA=; c=relaxed/simple; d=groups.io; h=DKIM-Filter:Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240830; t=1729542372; v=1; x=1729801570; b=XNcO8hjklIXj29xDUfMyHlvkGA/3iCrQpn9v5mseYDEmW081rxl63ZXFP7Fzutwj1giYsnvM nGXTreOyZh0qmcbYK/12y3i57yRBd6GmJiON7k+NvFn4/XuaREQxUsWT97KAaJJYcqX+5N3xgsV QDjNWJAQAVWA8P76PETuFxpHOV+NaQiWxEDrz5L+DVNy4Q1kWcAoWLjqHBUCdCeFqWtcUsWGl27 5UHrB7AVSr9rhI43il/Qu6+dVyJQsK39r3YmNzWfyfRuzDkhdPxsPd/oHH5Q7KN6+lnxnREK0t2 EKZexIZjcejDnydU1k6FcmjTUm14LQccgQNhYAFpZWBkg== X-Received: by 127.0.0.2 with SMTP id 7YNUYY7687511xOaZxFUpJM6; Mon, 21 Oct 2024 13:26:10 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.2510.1729542365388056536 for ; Mon, 21 Oct 2024 13:26:05 -0700 X-Received: from [10.137.194.171] (unknown [131.107.159.43]) by linux.microsoft.com (Postfix) with ESMTPSA id E32AA210D8B7; Mon, 21 Oct 2024 13:26:04 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E32AA210D8B7 Message-ID: <5a0d2a4f-a423-4ef3-a07b-18e69e7d1241@linux.microsoft.com> Date: Mon, 21 Oct 2024 13:26:04 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [edk2-CCodingStandardsSpecification PATCH 1/1] Prefer use of `static` C keyword over EDK2 type `STATIC` To: devel@edk2.groups.io, pedro.falcato@gmail.com Cc: rebecca@bsdio.com, "Kinney, Michael D" References: <20241011012040.274642-1-rebecca@bsdio.com> <591659ac-1d4a-43bd-b953-1032e5a7b8b0@linux.microsoft.com> From: "Oliver Smith-Denny" In-Reply-To: Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Mon, 21 Oct 2024 13:26:05 -0700 Resent-From: osde@linux.microsoft.com Reply-To: devel@edk2.groups.io,osde@linux.microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 4BEBkreXANRMQUXcErkuFX5rx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240830 header.b=XNcO8hjk; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linux.microsoft.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io On 10/21/2024 1:21 PM, Pedro Falcato wrote: > On Mon, Oct 21, 2024 at 9:05=E2=80=AFPM Oliver Smith-Denny > wrote: >> >> On 10/21/2024 12:42 PM, Pedro Falcato wrote: >>> On Mon, Oct 21, 2024 at 3:49=E2=80=AFPM Rebecca Cran via groups.io >>> wrote: >>>> >>>> Thanks, I'll fix it. >>>> >>>> Could you confirm whether the change from STATIC to static is somethin= g >>>> we want to go ahead with, or do we want to keep STATIC to allow >>>> GoogleTest to work? >>> >>> You don't need STATIC, doing stuff like -Dstatic=3D (or just #define >>> static in C code) Just Works. For GCC at least. >>> >>> proof of horribleness: https://godbolt.org/z/EvMd6hev8 >>> >> >> The issue here is that C uses one keyword for two distinct things: >> file private members and local variables that keep state across calls, >> i.e. real static variables. >=20 > That's an interesting problem, but I'm afraid the current EDK2 coding > style would recommend STATIC for local variables too. >=20 > https://tianocore-docs.github.io/edk2-CCodingStandardsSpecification/relea= se-2.20/5_source_files/56_declarations_and_types.html#56-declarations-and-t= ypes > says: >=20 > 5.6.1.2 The use of int, unsigned, char, void, static, long is a > violation of the coding convention. >=20 > so: >=20 > INT Foo() > { > STATIC INT Variable =3D 0; > return Variable++; > } >=20 > would be the sanctioned way to pull off this kind of stuff. So STATIC > gains us nothing (neither does INT, LONG, CHAR, VOID, or CONST). >=20 Yeah, so what we did in Mu was leverage the fact that static locals are relatively uncommon and code coverage is extremely low, so that there=20 was only one current instance of a static local under test. And we changed that to lowercase static. So now STATIC bought us that we could undef it when building HOST_APPLICATIONs. Was I happy with that approach? No. But, we were trying to evaluate the usefulness of GoogleTest and this was one issue that had to be fixed in order for us to use it. Oliver -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#120640): https://edk2.groups.io/g/devel/message/120640 Mute This Topic: https://groups.io/mt/108941574/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-