Unfortunately for you, C doesn't work that way. There is no notion of modules as a language feature. What you will end up with is a collection of self-contained programs, each in a single source file.Originally Posted by boqsc
You can already do that by editing and sharing C source files and their associated headers.Originally Posted by boqsc
You cannot get around the fact that there can be only one main function in a C program, so what you are trying to do is doomed to fail.Originally Posted by boqsc
That's exactly what your compiler is telling you with the error message about "redefinition of 'main'": there can be only one main function in a C program. There may be a hacky workaround: define the main function in each source file, then #define main some_random_name before including the source file and then #undef main after including it. But you're still going to run into other multiple definition errors when your inclusion graph becomes more complex. It may be possible to avoid redefinition errors using the "header-only" approach seen in C++ by using the inline keyword liberally, but that assumes that your target compiler supports it sufficiently.Originally Posted by boqsc
The way I see it, if this approach is particularly important to you, you would be better served by switching to a programming language that would enable you to do what you want to do.