cl65 confusing behavior due to c64 defaulting
pm100 opened this issue · comments
This took me a long time to unearth.
compiling like this
cl64 test.c -t sim6502
produces a file that runs under sim6502 but has been compiled and assembled for c64. This in particular means that printfs dont work because
- the format string gets upper cased (%d -> %D) and so are ignored
- the \n gets converted to a \r. On sim65 this results in no output being produced at all
this is due to cl65 doing this
PS C:\work\db65> ..\forks\cc65\bin\cl65 -d argtest.c -t sim6502
Executing: C:\work\forks\cc65\bin\cc65 -d -t c64 argtest.c
Executing: C:\work\forks\cc65\bin\ca65 -t c64 argtest.s
Executing: C:\work\forks\cc65\bin\ld65 -o argtest -t sim6502 argtest.o sim6502.lib
compile and assemble is done for c64, link is done for sim65
I think this should be treated as an error. If the -t flag is present after the source file names it should be rejected. I have spent a huge amount of time trying to work out why things just stopped working, seemingly at random (this was when I was working on a rewrite of __printf.s so I assumed it was my printf code)
I'd accept a patch that makes it error out if -t is first used after a source file - i can see legit uses of using it multiple times in complex situations, and its a bit harsh to completely remove this feature. Its fair to force the first usage before any source files though, i guess - as that probably always enforces the correct/intended behaviour too.