1. I also use these kind of enums for constants. Why? Because enum values don't have "type", sometimes it prevents warning when assigning value to specific variable. Another, probably more important reason, is that enums have a scope ("namespace"), so they don't pollute whole translation unit below like define would. I can put them inside function or whatever.
2. offsetof is a macro. offsetof(BufHdr, buf) expands to something like:
| sizeof((char*)&((BufHdr*)0)->buf - (char*)0)
|
Second argument to macro is always a member of struct that is first argument. No matter what local variables you have. Depending on compiler, sometimes offsetof is implemented as compiler builtin, not a macro. But the result it the same.
To run everything in VS, just select File -> New -> Project. Select "Win32 Console Application", enter location at bottom. On next dialog choose "Application Type" = "Console application", and select "Empty project" checkbox. Then press Finish. Now drag ion.c into project and that's it. It should work.