Multiple Translation Units for Lite-C

Posted By: Dark_samurai

Multiple Translation Units for Lite-C - 01/18/14 12:53

Hi JCL,

AFAIK there is no way to use multiple translation units in Lite-C like in standard C. I always found it very uncomfortable and very bad programming style to include C files (#include "unit1.c"). Is it possible to change the compiler to handle every .c file of a SED project as seperate translation unit? Would this require a big change in the compiler code?

Thanks!
Posted By: Rackscha

Re: Multiple Translation Units for Lite-C - 01/24/14 12:00

@Dark_samurai: you mean: so we can just include the h files and generate object files from each c file?(Which are then linked)
Posted By: Dark_samurai

Re: Multiple Translation Units for Lite-C - 01/24/14 14:56

Yes that's what I ment. In ANSI C, you don't need to include every *.c file into the main *.c file like in Lite-C. Every *.c file of the project is handled as one small unit. The linker makes 1 executeable out of the object files of every c file.

Thus information hiding can be realised (one *.c file doesn't see the global variables of another *.c file if it isn't defined as extern in the header, same for "private" function which are only seen in one *.c file). This would help making programming in Lite-C "cleaner" than it is now.
Posted By: Rackscha

Re: Multiple Translation Units for Lite-C - 01/24/14 15:21

Yes, for sure.

And you can use/declare things within a c file without fear of causing problems with other c files.
© 2024 lite-C Forums