c++cmacros

What Turing complete macro languages are available for C/C++


Preamble

One of the major points which Lispers claim as a bonus over more "mainstream" languages is that the macro language is actually Turing complete (I cannot recall if this was Paul Graham in On Lisp or if it was Conrad Barski in Land Of Lisp)1, and to an outsider, at least, this seems true -- pre-processor directives in C/C++ do not seem to be Turing complete (honestly, they feel like more of an annotation syntax).

And now... the question

  1. Is this an accurate assessment? Having only dabbled in C, this strikes me as yet another point where Lispers are over-zealous
  2. Are there any Turing complete macro languages (for C/C++) which are worth noting?
    • Are there any which are in the works or abortive attempts which might be worth looking for in the future?
    • I have heard that Python can now serve as a backbone to compile C/C++ (implying that Python can be used to write the macros), but I have not seen confirmation of this. Is it true?

(I will refrain from asking the opinion questions like "what are the best...")

1. Both are really good books by the way, just sayin'


Solution

  • C macros are in fact Turing complete, if processed more than once. Check out this related question and in particular the Turing machine implementation linked to in the accepted answer.

    But yes, this is cheating. The solution used there strongly implies that C macros really aren’t Turing complete.