Preprocessor File Extension Conventions

Ashley Yakeley ashley@semantic.org
Mon, 11 Dec 2000 18:17:55 -0800


At 2000-12-11 03:26, Marcin 'Qrczak' Kowalczyk wrote:

>When multiple preprocessors are being applied, it's not obvious what
>extensions to use. I tried to allow such stacking in my hsc2hs
>preprocessor by letting it accept any name ending in "c" and creating the
>output file with this "c" removed, thus turning foo.hsc into foo.hs and
>foo.lhsc into foo.lhs.
>
>Perhaps it would be better to mark a source to be preprocessed by
>appending a whole new extension with its own dot instead of modifying the
>old extension, like autoconf turning config.h.in into config.h.

I prefer the other way around. For instance, compiling 'foo.c' gives 
object file 'foo.c.o'. A parser might start as a bison file 'parser.y', 
converted to 'parser.y.h' and 'parser.y.c', and compiled to object file 
'parser.y.c.o'. The advantage is that you can look at the filename and 
see how the file was made (or how it should be made by a make tool). 
Also, 'foo.a' (assembly) and 'foo.c' won't collide.

So 'foo.hsc' could go to 'foo.hsc.hs', and 'foo.lhsc' could go to 
'foo.lhsc.hs'.

>Preprocessors in general may produce more files. For example hsc2hs
>sometimes produces .c and .h files as well. This requires a naming
>convention too.

... 'foo.hsc.c', 'foo.hsc.h'.

-- 
Ashley Yakeley, Seattle WA