Is C++ preprocessor metaprogramming Turing-complete?
I know C++ template metaprogramming is Turing-complete. Does the same thing hold for preprocessor metaprogramming? No. The C++ preprocessor does not allow for unlimited state. You only have a finite number of on/off states, plus a include stack. This makes it a push-down automaton, not a turing machine (this ignores also the fact that preprocessor recursion is limited - but so is template recursion). However, if you bend your definitions a bit, this is possible by invoking the preprocessor multiple times - by allowing the preprocessor to generate a program which re-invokes the preprocessor,