C++
#include <iostream> #define Q(x,y) x ## y #define P(x,y) Q(x, y) #define print S P(s, __LINE__) = struct S { const char *s; S(const char *s): s(s) {} ~S() { std::cout << s; } }; int main() { print "Line1"; print "Line2"; print "Line3"; print "Line4"; } (Local variables are destroyed in reverse order of declaration.)