Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Is the C99 preprocessor Turing complete?

After discovering the Boost preprocessor's capabilities I found myself wondering: Is the C99 preprocessor Turing complete?

If not, what does it lack to not qualify?

Answer*

Draft saved
Draft discarded

Required fields are marked with *

Cancel
4
  • If you mean the 115 point answer by Paul Fultz II below: it confirms this answer. Commented Aug 20, 2017 at 10:56
  • 3
    The limit is in the language itself, but not because of the spec, but because we must write the scans to evaluate the algorithm in the language itself, which there is no mechanism to apply an infinite number of scans. Commented Oct 18, 2017 at 23:26
  • To add to the lack of recursiveness, that seems to be (under)specified by the standard. §6.10.3.5 paragraph 4 shows an example of two macros calling each other and states: "There are cases where it is not clear whether a replacement is nested or not [...]. Strictly conforming programs are not permitted to depend on such unspecified behavior. " Commented Mar 13, 2021 at 15:51
  • @reinierpost technically, the 217 point answer (now above smh) doesn't actually confirm this answer, as someone else could still prove that CPP is TC. However, it seems like no-one has, and all who attempt use LARGE NUMBERS of macros. The fact that the algorithm is designed to always terminate is enough for me (see alinsoar's answer). Commented Apr 30, 2022 at 11:18