Skip to content

Instantly share code, notes, and snippets.

@soap-DEIM
Created May 16, 2014 02:41
Show Gist options
  • Save soap-DEIM/cad92a653ba113777809 to your computer and use it in GitHub Desktop.
Save soap-DEIM/cad92a653ba113777809 to your computer and use it in GitHub Desktop.
graphicviz-dot example
#include <cstdio>
#include <fstream>
#define VISUAL(caller, callee, ofs) \
ofs << caller << "->"; \
callee(ofs); \
ofs << ';' << '\n'
void foo(std::ofstream &ofs)
{
printf("%s\n", __func__);
ofs << __func__;
}
void bar(std::ofstream &ofs)
{
printf("%s\n", __func__);
ofs << __func__;
}
int main()
{
std::ofstream ofs("viz.dot");
printf("%s\n", __func__);
ofs << "digraph" << '{' << '\n';
VISUAL(__func__, foo, ofs);
VISUAL(__func__, bar, ofs);
ofs << '}' << '\n';
ofs.close();
return 0;
}
/* to generate png, execute: */
/* dot -Tpng viz.dot -o viz.png */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment