Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Fedora Packaging (http://www.linux-archive.org/fedora-packaging/)
-   -   When to use a leading underscore? (http://www.linux-archive.org/fedora-packaging/699594-when-use-leading-underscore.html)

Björn Persson 08-31-2012 09:33 PM

When to use a leading underscore?
 
As maintainer of fedora-gnat-project-common I sometimes work on RPM macros for
use in Ada packages. Every time I define a new macro I have trouble deciding
whether its name should begin with an underscore or not. I know that there is
some technical difference but I've never quite understood what practical
difference it makes.

I've been trying to imitate macros with a similar function, so I defined
_GNAT_project_dir with a leading underscore in analogy with _libdir and
others. Macros containing command line flags for build tools I've defined
without a leading underscore in analogy with optflags, but then there are
_smp_mflags and the hardening macros which have the underscore, and
__global_cflags and __global_ldflags even have two leading underscores.

Could someone explain what difference a leading underscore makes and give some
guidance on when I should use it?

Is a double leading underscore functionally different from a single one, or is
that just some kind of naming convention?

Björn Persson

--
packaging mailing list
packaging@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/packaging

indent man 09-03-2012 08:47 AM

When to use a leading underscore?
 
You can take a look at top comment in /usr/lib/rpm/macrosNot sure what it means, however :)
Cheers

On Fri, Aug 31, 2012 at 11:33 PM, Björn Persson <bjorn@xn--rombobjrn-67a.se> wrote:

As maintainer of fedora-gnat-project-common I sometimes work on RPM macros for

use in Ada packages. Every time I define a new macro I have trouble deciding

whether its name should begin with an underscore or not. I know that there is

some technical difference but I've never quite understood what practical

difference it makes.



I've been trying to imitate macros with a similar function, so I defined

_GNAT_project_dir with a leading underscore in analogy with _libdir and

others. Macros containing command line flags for build tools I've defined

without a leading underscore in analogy with optflags, but then there are

_smp_mflags and the hardening macros which have the underscore, and

__global_cflags and __global_ldflags even have two leading underscores.



Could someone explain what difference a leading underscore makes and give some

guidance on when I should use it?



Is a double leading underscore functionally different from a single one, or is

that just some kind of naming convention?



Björn Persson



--

packaging mailing list

packaging@lists.fedoraproject.org

https://admin.fedoraproject.org/mailman/listinfo/packaging

--
packaging mailing list
packaging@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/packaging

indent man 09-03-2012 08:54 AM

When to use a leading underscore?
 
Or maybe for historical reasons ?http://www.rpm.org/wiki/PackagerDocs/Macros#ConfigurationusingMacros
If you find the right answer, please let me know, I'm interested too.


On Mon, Sep 3, 2012 at 10:47 AM, indent man <indentman@gmail.com> wrote:

You can take a look at top comment in /usr/lib/rpm/macrosNot sure what it means, however :)
Cheers

On Fri, Aug 31, 2012 at 11:33 PM, Björn Persson <bjorn@xn--rombobjrn-67a.se> wrote:


As maintainer of fedora-gnat-project-common I sometimes work on RPM macros for

use in Ada packages. Every time I define a new macro I have trouble deciding

whether its name should begin with an underscore or not. I know that there is

some technical difference but I've never quite understood what practical

difference it makes.



I've been trying to imitate macros with a similar function, so I defined

_GNAT_project_dir with a leading underscore in analogy with _libdir and

others. Macros containing command line flags for build tools I've defined

without a leading underscore in analogy with optflags, but then there are

_smp_mflags and the hardening macros which have the underscore, and

__global_cflags and __global_ldflags even have two leading underscores.



Could someone explain what difference a leading underscore makes and give some

guidance on when I should use it?



Is a double leading underscore functionally different from a single one, or is

that just some kind of naming convention?



Björn Persson



--

packaging mailing list

packaging@lists.fedoraproject.org

https://admin.fedoraproject.org/mailman/listinfo/packaging



--
packaging mailing list
packaging@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/packaging

Panu Matilainen 09-04-2012 05:15 AM

When to use a leading underscore?
 
On 09/01/2012 12:33 AM, Björn Persson wrote:

As maintainer of fedora-gnat-project-common I sometimes work on RPM macros for
use in Ada packages. Every time I define a new macro I have trouble deciding
whether its name should begin with an underscore or not. I know that there is
some technical difference but I've never quite understood what practical
difference it makes.

I've been trying to imitate macros with a similar function, so I defined
_GNAT_project_dir with a leading underscore in analogy with _libdir and
others. Macros containing command line flags for build tools I've defined
without a leading underscore in analogy with optflags, but then there are
_smp_mflags and the hardening macros which have the underscore, and
__global_cflags and __global_ldflags even have two leading underscores.

Could someone explain what difference a leading underscore makes and give some
guidance on when I should use it?

Is a double leading underscore functionally different from a single one, or is
that just some kind of naming convention?


A name is just a name, there's no functional difference. Once upon a
time in a faraway galaxy there might have been, but that's nothing you
need to worry about. These days its just a naming convention, albeit a
rather blurry one.


The bottom line: as long as your macros are "namespaced" (such as your
GNAT/_GNAT prefix) to limit the possibility of clashes with others,
you're technically free to call them whatever you want. Following
existing conventions is not a bad idea though.


- Panu -


--
packaging mailing list
packaging@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/packaging

Björn Persson 09-04-2012 05:56 AM

When to use a leading underscore?
 
Panu Matilainen wrote:
> A name is just a name, there's no functional difference. Once upon a
> time in a faraway galaxy there might have been, but that's nothing you
> need to worry about. These days its just a naming convention, albeit a
> rather blurry one.
>
> The bottom line: as long as your macros are "namespaced" (such as your
> GNAT/_GNAT prefix) to limit the possibility of clashes with others,
> you're technically free to call them whatever you want. Following
> existing conventions is not a bad idea though.

OK, one problem less to worry about. Thanks!

Björn Persson

--
packaging mailing list
packaging@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/packaging


All times are GMT. The time now is 06:52 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.