Page 1 of 1

Source compiles or not depending on file name?

Posted: Sat Oct 09, 2021 5:30 pm
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.

?????????

Re: Source compiles or not depending on file name?

Posted: Sat Oct 09, 2021 6:02 pm
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.

Re: Source compiles or not depending on file name?

Posted: Tue Oct 12, 2021 5:42 pm
by cborn
Hi
what hapens with 0main.c , without the underscore?

Re: Source compiles or not depending on file name?

Posted: Tue Oct 12, 2021 8:10 pm
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]$ 

Re: Source compiles or not depending on file name?

Posted: Tue Oct 12, 2021 8:12 pm
by dom
I forgot to mention, this was fixed a couple of days ago.

Re: Source compiles or not depending on file name?

Posted: Wed Oct 13, 2021 10:41 am
by jorgegv
it works indeed, thanks!