I'm using GNU Make v4.4.1.
I've figured out what the problem is ?? the Makefile and the error are below.
Thanks for the reply.


Paul Smith said: "Trailing spaces at the end of a variable assignment, 
whether followed by a comment or not, must be preserved."


makefile:
# buggy Makefile for Windows + w64devkit gcc
TARGET = output  # test
BUILD_DIR = build


EXE = $(BUILD_DIR)/$(TARGET).exe
MAP = $(BUILD_DIR)/$(TARGET).map


CFLAGS := -Wall -O2
LFLAGS := -Wl,-Map=$(MAP)


all: $(EXE)


$(EXE): hello.c Makefile | $(BUILD_DIR)
        gcc $(CFLAGS) hello.c $(LFLAGS) -o $@


$(BUILD_DIR):
        mkdir $@


clean:
        rd /s /q $(BUILD_DIR)


$(info TARGET raw: |$(TARGET)|)
$(info MAP   raw: |$(MAP)|)


# *** EOF ***


error:
S:/ # make
TARGET raw: |output  |
MAP   raw: |build/output  .map|
mkdir build
gcc -Wall -O2 hello.c -Wl,-Map=build/output  .map -o build/output
D:/Kit/w64devkit/bin/ld.exe: cannot find .map: No error
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:14: build/output] Error 1







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





What version are you using and what's the EXACT output and FULL
makefile that you see a problem with?


Philip Guenther

On Sat, Nov 7, 2026 at 9:46?6?2PM DeDf <[email protected]&gt; wrote:
&gt;
&gt; I found a bug regarding inline comments. When adding an inline comment # 
after an = assignment statement, if there is some space before the #, 
compilation fails.
&gt;
&gt; If a makefile contains the following statements:
&gt; TARGET = output
&gt; This line works fine.
&gt;
&gt; TARGET = output&nbsp;&nbsp;&nbsp; # test
&gt; This line reports an error.
&gt;
&gt; Suggested fix:
&gt; read.c remove_comments():
&gt;
&gt; static void
&gt; remove_comments (char *line)
&gt; {
&gt;&nbsp;&nbsp;&nbsp;&nbsp; if (line)
&gt;&nbsp;&nbsp;&nbsp;&nbsp; {
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char *comment = 
find_map_unquote (line, MAP_COMMENT|MAP_VARIABLE);
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (comment)
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
//char b = 0;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
*comment = '\0';&nbsp; /* Cut off the line at the #.&nbsp; */
&gt;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
while (comment != line)
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 if (--comment == line)
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 break;
&gt;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 if (*comment == ' ' || *comment == '\t')&nbsp; // Remove ' ' and '\t' before 
comment.
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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