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]>;
????????: 2026??11??8??(??????) ????3:34
??????: "DeDf"<[email protected]>;
????: "bug-make"<[email protected]>;
????: 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]> wrote:
>
> 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.
>
> If a makefile contains the following statements:
> TARGET = output
> This line works fine.
>
> TARGET = output # test
> This line reports an error.
>
> Suggested fix:
> read.c remove_comments():
>
> static void
> remove_comments (char *line)
> {
> if (line)
> {
> char *comment =
find_map_unquote (line, MAP_COMMENT|MAP_VARIABLE);
> if (comment)
> {
>
//char b = 0;
>
*comment = '\0'; /* Cut off the line at the #. */
>
>
while (comment != line)
> {
>
if (--comment == line)
>
break;
>
>
if (*comment == ' ' || *comment == '\t') // Remove ' ' and '\t' before
comment.
>
{
>
//
if (!b)
>
//
{
>
//
printf("remove_comments() |%s|\n", line);
>
//
b = 1;
>
//
}
>
>
*comment = '\0';
>
}
>
else
>
break;
> }
> }
> }
> }
>
> Thanks,
> form DeDf