bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: feature requests: $(__FILE__) and $(__LINE__) textual macros


From: Basile Starynkevitch
Subject: Re: feature requests: $(__FILE__) and $(__LINE__) textual macros
Date: Sat, 27 Jan 2024 20:27:10 +0100
User-agent: Mozilla Thunderbird



On 1/27/24 20:11, Paul Smith wrote:
On Sat, 2024-01-27 at 18:06 +0100, Basile Starynkevitch wrote:
For non-trivial GNUmakefile-s on Linux it would be nice to have a
$(__FILE__) and $(__LINE__) textual macros of GNU make.

It would be great if you could provide examples where these would be
useful, especially examples that are not already covered by the output
of the -p option to GNU Make.

make -p don't show (unfortunately) the line number in makefiles. Alternatively, a runtime option for make -p (perhaps --show-line-numbers) would be nice.

I'm not saying we shouldn't introduce these, although I think you
misunderstand how tricky it would be to use them (for example, if you
set:

     FOO = $(__LINE__)

This would be expanded at Makefile parsing time. Not at function invocation time.

If I started to implement it, I would add

  FT_ENTRY ("__LINE__",           0,  0,  0,  func__LINE__),

in GNU make's  src/function.c file.


and probably func__LINE__ would return some ebuf->floc.lineno


For
  FT_ENTRY ("__FILE__",           0,  0,  0,  func__FILE__),

I guess func__FILE__ would return some ebuf->floc.filenm

So my intuition is that this feature is easy to implement.

Sorry, English is not my native language, but I was thinking of $(__FILE__) and $(__LINE__) being implemented as close as possible to the GNU make parsing code.

Thanks for your email.

Regards
--
Basile Starynkevitch             <basile@starynkevitch.net>
(only mine opinions / les opinions sont miennes uniquement)
92340 Bourg-la-Reine, France
web page: starynkevitch.net/Basile/
See https://github.com/RefPerSys/RefPerSys




reply via email to

[Prev in Thread] Current Thread [Next in Thread]