You aren't required to only use the C source code transformation tools that a default install of GCC provides.
You aren't required to only use the C source code transformation tools that a default install of GCC provides.
If you're using VS, you're going to want to use the included pre-build steps in the vcproj to generate the source. Unfortunately, you can't just edit the source in place, unless your team is absolutely in love with your SCS' rollback capability. So that means that in order to edit the code, you need to open it up in either another project, or open it outside the IDE's solution environment.
It also removes the ability to do partial rebuilds, since every file will be necessarily touched by the preprocessing script before compiling, so it's a "new" file as far as the IDE is concerned.
Debugging becomes a chore, because the code in source control is not the code that was compiled, breaking line counts and breakpoints.
Finally, it's a deployment nightmare for your build staff, since they need to make sure that everyone is standardized on the same perl version, maintain the scripts in addition to the makefiles, and make sure that everyone's dev environment works with it.
But sure, if that's not one of the limitations you're working under then code generation through another language is definitely a possibility.
If you're about to reply it's a risk you'd take... me too, in general. CPP sucks. But not wanting to introduce that risk is a valid choice in many cases.
No it doesn't. It only requires a single rule in your Makefile. Something like:
%.c: %.cpre preprocess.pl; ./preprocess.pl <$^ >$@The usual workaround for such situations is to add the preprocessed files into source control as well, so they are available when a user is building the code. However, this ends up even more ugly.
Doing weird things to a C file (while occasionally useful) is just increasing the technical debt of your teammates later.
(though, we do have a closure-ish macro in our codebase that's pretty nifty, so do as I say not as I do etc.)
>> If you really want to do complicated lisp-style meta-programming stuff
> Increases technical debt
Yep. The sane solution is to just not do stuff like this at all. In rare
situations it ends up being worth it.