Re: Naming conventions (was Re: valgrind leak I can't find)

Liste des GroupesRevenir à cl c 
Sujet : Re: Naming conventions (was Re: valgrind leak I can't find)
De : thiago.adams (at) *nospam* gmail.com (Thiago Adams)
Groupes : comp.lang.c
Date : 22. Aug 2024, 16:01:07
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <va7gb3$f2d0$1@dont-email.me>
References : 1 2 3 4 5
User-Agent : Mozilla Thunderbird
On 22/08/2024 10:32, Janis Papanagnou wrote:
On 22.08.2024 14:01, Annada Behera wrote:
On Thu, 2024-08-22 at 08:18 -0300, Thiago Adams wrote:
On 22/08/2024 08:01, Bart wrote:
On 22/08/2024 09:41, Mark Summerfield wrote:
>
This is the type's struct:
>
typedef struct {
      int _size;
      int _cap;
      char** _values;
} VecStr;
>
What's with the leading underscores for member names?
 A convention. (I.e. one convention amongst dozens.)
 
>
It means ending with ->_ later on, which seems pointless extra
clutter.
>
>
C++ is responsible for this.
 I don't think so. I've seen such conventions in many places, also
very often in C contexts. Even standards use naming conventions.
(This is no valuation. I don't give a valuation. Not yet.)
C++ also made the use of "struct/union/enum" before tags optional.
For example:
struct X x;
In C++, we can write:
X x;
Consequence?
Programmers started using a suffix "C" for classes and "E" for enums.
For example:
CArray array;
EType type;
In C, we have a similar situation where it's sometimes unclear where a variable comes from.
Consider this code:
void f(int arg1){
   i = 2;
}
This can happen with external variables.
For instance:
int i;
void f(int arg1){
   i = 2;
}
In this situation, I use a prefix "s_" for the variable, like this:
int s_i;

Date Sujet#  Auteur
22 Aug 24 * valgrind leak I can't find26Mark Summerfield
22 Aug 24 +- Re: valgrind leak I can't find1Ben Bacarisse
22 Aug 24 +* Re: valgrind leak I can't find11Bart
22 Aug 24 i`* Re: valgrind leak I can't find10Thiago Adams
22 Aug 24 i `* Re: valgrind leak I can't find9Annada Behera
22 Aug 24 i  +* Naming conventions (was Re: valgrind leak I can't find)6Janis Papanagnou
22 Aug 24 i  i`* Re: Naming conventions (was Re: valgrind leak I can't find)5Thiago Adams
23 Aug 24 i  i +- Re: Naming conventions (was Re: valgrind leak I can't find)1Janis Papanagnou
23 Aug 24 i  i `* Re: Naming conventions (was Re: valgrind leak I can't find)3James Kuyper
25 Aug 24 i  i  `* Re: Naming conventions (was Re: valgrind leak I can't find)2Janis Papanagnou
26 Aug 24 i  i   `- Re: Naming conventions (was Re: valgrind leak I can't find)1James Kuyper
24 Aug 24 i  `* Re: valgrind leak I can't find2Blue-Maned_Hawk
24 Aug 24 i   `- Re: valgrind leak I can't find1Keith Thompson
22 Aug 24 +- Re: valgrind leak I can't find1Stefan Ram
22 Aug 24 +- Re: valgrind leak I can't find1Ike Naar
22 Aug 24 +- Re: valgrind leak I can't find1Stefan Ram
22 Aug 24 +- Re: valgrind leak I can't find1Kaz Kylheku
22 Aug 24 `* Re: valgrind leak I can't find9Mark Summerfield
22 Aug 24  +- Re: valgrind leak I can't find1Kaz Kylheku
23 Aug 24  +* Re: valgrind leak I can't find6Stefan Ram
23 Aug 24  i`* Re: valgrind leak I can't find5Bart
23 Aug 24  i `* Re: valgrind leak I can't find4Michael S
23 Aug 24  i  +* Re: valgrind leak I can't find2James Kuyper
23 Aug 24  i  i`- Re: valgrind leak I can't find1James Kuyper
23 Aug 24  i  `- Re: valgrind leak I can't find1David Brown
23 Aug 24  `- Re: valgrind leak I can't find1James Kuyper

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal