ok, you are right.

if "Trailing spaces at the end of a variable assignment, 
whether followed by a comment or not, must be preserved." is a rule, 
Then it's not a bug.



Thanks,
form DeDf




------------------ ???????? ------------------
??????: "psmith"<[email protected]&gt;; 
????????: 2026??11??8??(??????) ????9:46
??????: "DeDf"<[email protected]&gt;; "bug-make"<[email protected]&gt;; 
????: Re: [bug report] I found a bug regarding inline comments.



2026-11-08 at 09:39 +0800, DeDf wrote:
&gt; If a makefile contains the following statements:
&gt; TARGET = output
&gt; This line works fine.
&gt; 
&gt; TARGET = output&nbsp; &nbsp; # test
&gt; This line reports an error.

Unfortunately this is not a helpful bug report.&nbsp; If that line "reports
an error", please show us the error.

My suspicion, based on experience and on the proposed change you
supplied, is that this line does NOT report an error at all, but rather
when you use this variable later in your makefile, it doesn't behave as
you expect.

For example, you may have elsewhere in your makefile something like
this:

&nbsp;&nbsp; foo: $(TARGET)/myfile

and this doesn't work as you want because, after you added the comment,
the value of the TARGET variable contained trailing space and this
becomes:

&nbsp;&nbsp; foo: output&nbsp;&nbsp;&nbsp; /myfile

I understand that is surprising and unusual but unfortunately it's
expected, documented, and even mandated by the POSIX standard. 
Trailing spaces at the end of a variable assignment, whether followed
by a comment or not, must be preserved.


In makefiles I recommend that you do not use end-of-line comments.&nbsp; If
you want to support them you must rewrite your references, e.g.:

&nbsp;&nbsp; foo: $(strip $(TARGET))/myfile

Reply via email to