[z88dk-dev] zcc makes exception for .c files in not making temp copy

Bridge to the z88dk-developers mailing list
Post Reply
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

[z88dk-dev] zcc makes exception for .c files in not making temp copy

Post by alvin »

In zcc.c::add_file_to_process() an exception is made for .c files in that they are not copied to a temporary file before processing. In the main switch "case CFILE:" where .c files are processed, that exception is accommodated by a YES value in the last parameter to process(). This ensures the original .c file is used for compilation. This treatment only applies to .c files -- is there a reason for doing this?

What is happening is that .c.m4 files, which are .c files generated from an m4 macro, do not get compiled with that YES there -- instead the c compilation uses the original .c.m4 file to compile with. If I get rid of the YES and copy all .c files over in add_file_to_process(), then things will work as they should.



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

Post by dom »

On 24 Sep 2016, at 00:18, alvin (alvin_albrecht@...) <lists@...> wrote:

In zcc.c::add_file_to_process() an exception is made for .c files in that they are not copied to a temporary file before processing. In the main switch "case CFILE:" where .c files are processed, that exception is accommodated by a YES value in the last parameter to process(). This ensures the original .c file is used for compilation. This treatment only applies to .c files -- is there a reason for doing this?
Yes. It means that any code errors are reported with the original filename and not a /tmp one.
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

Yes. It means that any code errors are reported with the original filename and not a /tmp one.
I also found out it messes with include paths when the preprocessor runs. I put it back to the way it was so that include paths are correct for cpp and I copied this for m4 processing because original file processing is probably needed there for proper include paths too.

For error reporting, I was thinking we could try to capture text output from process() and do strstr() on lines output to match the temp filename and, if found, replace with original filename before copying text messages to output. Then we wouldn't have to print a key at all for files other than .c. But I haven't tried that yet.



------------------------------------------------------------------------------
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

What is happening is that .c.m4 files, which are .c files generated from an m4 macro, do not get compiled with that YES there -- instead the c compilation uses the original .c.m4 file to compile with. If I get rid of the YES and copy all .c files over in add_file_to_process(), then things will work as they should.
I forgot to mention it on the list but I added an m4 pre-processing step to zcc. zcc will now process files with extensions .h.m4, .inc.m4, .c.m4, .s.m4, .asm.m4, passing them through m4 before further processing in the current compile.

There's a short bit of documentation at the end of this section:

http://www.z88dk.org/wiki/doku.php?id=l ... uick_start

(That page I keep current for new c lib compiles and information on zcc, etc. The tools related information applies to classic compiles too).



------------------------------------------------------------------------------
Post Reply