<?xml version="1.0" ?><entry xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom" xmlns:planet="http://planet.intertwingly.net/"><id>https://blog.nelhage.com/2010/07/implementing-an-edsl-in-cpp/</id><link href="https://blog.nelhage.com/2010/07/implementing-an-edsl-in-cpp/" rel="alternate" type="text/html"/><title>Implementing a declarative mini-language in the C preprocessor</title><summary>Last time, I announced Check Plus, a declarative language for defining Check tests in C. This time, I want to talk about the tricks I used to implement a declarative minilanguage using the C preprocessor (and some GCC extensions).
The Problem We want to write some toplevel declarations that look like:
#define SUITE_NAME example BEGIN_SUITE(&quot;Example test suite&quot;); #define TEST_CASE core BEGIN_TEST_CASE(&quot;Core tests&quot;); … and so on, and somehow translate them into code that does the equivalent of:</summary><updated planet:format="July 04, 2010 03:54 PM">2010-07-04T15:54:55Z</updated><source><id>https://blog.nelhage.com/post/</id><author><name>Nelson Elhage</name></author><link href="https://blog.nelhage.com/post/" rel="alternate" type="text/html"/><link href="https://blog.nelhage.com/post/atom.xml" rel="self" type="application/rss+xml"/><subtitle>Recent content in Posts on Made of Bugs</subtitle><title>Posts on Made of Bugs</title><updated planet:format="September 13, 2026 04:37 AM">2026-09-13T04:37:09Z</updated><planet:format>rss20</planet:format><planet:bozo>false</planet:bozo><planet:items_per_page>60</planet:items_per_page><planet:name>Nelson Elhage</planet:name><planet:css-id>nelson-elhage</planet:css-id><planet:days_per_page>0</planet:days_per_page><planet:http_etag>&quot;5b2ae9eec2e293572f6ae5a000bd0161-ssl-df&quot;</planet:http_etag><planet:http_status>200</planet:http_status><planet:encoding>utf-8</planet:encoding></source></entry>