Source compiles or not depending on file name?

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
User avatar
jorgegv
Well known member
Posts: 287
Joined: Wed Nov 18, 2020 5:08 pm

Source compiles or not depending on file name?

Post by jorgegv »

I'm just puzzled by the following poltergeist that is happening to me with my current Z88DK (compiled from GIT sources about a month ago).

I have edited the file main.c with the following:

Code: Select all

// zcc +zx -compiler=sdcc -clib=sdcc_iy -create-app -o main main.c

#include <stdio.h>

void main(void) {
    puts("Hello world!");
}

This code compiles and runs as expected.

Now comes the good part: if I just RENAME the file main.c to 00_main.c, the following magically happens (this is a log of my terminal session):

Code: Select all

[jorgegv@endor rage1]$ cat main.c
// zcc +zx -compiler=sdcc -clib=sdcc_iy -create-app -o main main.c

#include <stdio.h>

void main(void) {
    puts("Hello world!");
}

[jorgegv@endor rage1]$ mv main.c 00_main.c
[jorgegv@endor rage1]$ cat 00_main.c
// zcc +zx -compiler=sdcc -clib=sdcc_iy -create-app -o main main.c

#include <stdio.h>

void main(void) {
    puts("Hello world!");
}

[jorgegv@endor rage1]$ zcc +zx -compiler=sdcc -clib=sdcc_iy -create-app -o main 00_main.c
Error at file '/tmp/tmpXXwe2Ho0.asm' line 1: syntax error
Errors in source file 00_main.c:
Error at file '/tmp/tmpXXwe2Ho0.asm' line 1: syntax error
[jorgegv@endor rage1]$ 

A file that perfectly compiles if it is called main.c, does not compile if called 00_main.c!!!!!

AFAIK, C imposes no naming conventions on the source file names, right?

Anyone has an explanation for this?

EDIT: This also happens if the compiler selected is SCCZ80. It looks that ZCC does not like that a source file name starts with a number. If I remove them from the beginning of the name everything works.

?????????
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Re: Source compiles or not depending on file name?

Post by dom »

That's a good one - I was wondering why this never came up before, and it's due to the C_LINE directives that have been added recently.

I did think they were just strings, but z80asm is obviously trying to parse them in some way. I've raised an issue here: https://github.com/z88dk/z88dk/issues/1883 and hopefully Paulo will fix it up.
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: Source compiles or not depending on file name?

Post by cborn »

Hi
what hapens with 0main.c , without the underscore?
User avatar
jorgegv
Well known member
Posts: 287
Joined: Wed Nov 18, 2020 5:08 pm

Re: Source compiles or not depending on file name?

Post by jorgegv »

cborn wrote: Tue Oct 12, 2021 5:42 pm Hi
what hapens with 0main.c , without the underscore?
Same error as above:

Code: Select all

[jorgegv@endor rage1]$ cat 0main.c 
// zcc +zx -compiler=sdcc -clib=sdcc_iy -create-app -o main main.c

#include <stdio.h>

void main(void) {
    puts("Hello world!");
}
[jorgegv@endor rage1]$ zcc +zx -compiler=sdcc -clib=sdcc_iy -create-app -o main 0main.c
Error at file '/tmp/tmpXXwlFfRA.asm' line 1: syntax error
Errors in source file 0main.c:
Error at file '/tmp/tmpXXwlFfRA.asm' line 1: syntax error
[jorgegv@endor rage1]$ 
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Re: Source compiles or not depending on file name?

Post by dom »

I forgot to mention, this was fixed a couple of days ago.
User avatar
jorgegv
Well known member
Posts: 287
Joined: Wed Nov 18, 2020 5:08 pm

Re: Source compiles or not depending on file name?

Post by jorgegv »

it works indeed, thanks!
Post Reply