Skip to content

Instantly share code, notes, and snippets.

@mntmn
Created November 2, 2012 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mntmn/3997977 to your computer and use it in GitHub Desktop.
Save mntmn/3997977 to your computer and use it in GitHub Desktop.
A program that is ruby and C at the same time. Weird!
#ifndef false /*
#
# Written on Nov 2, 2012 by @mntmn
#
# This program is both ruby and C. Try it out:
#
# gcc hello.rb.c -o hello
# ./hello
#
# ruby hello.rb.c
#
def if_ruby
yield
end
def if_c
end
def main
yield
end
def void(f)
end
#*/
#endif
#include <stdio.h>
#define puts(X) printf(X);
#define if_ruby if(0)
#define if_c if(1)
void main() {
puts("Hello world.\n")
if_ruby {
puts("This is ruby.\n")
}
if_c {
puts("This is C.\n")
}
}
@grovdata
Copy link

😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment