3 ms·
If I had more sources which had done it well, I'd never had learned in the first place! :) For some of the safe arithmetic, this page has good tricks: http://
by angersock 12y ago
If I had more sources which had done it well, I'd never had learned in the first place! :)
For some of the safe arithmetic, this page has good tricks:
http://graphics.stanford.edu/~seander/bithacks.html#CopyIntegerSign http://graphics.stanford.edu/~seander/bithacks.html#CopyInte...
(note that Hacker's Delight is also handy!)
The Half-Life 1 SDK has some interesting examples of macro usage, though it's in C++. In general, a common place for people to use macros is defining state machines for game AI.
The Flipcode archives also have some old tutorials and articles which are handy: http://www.flipcode.com/archives/ http://www.flipcode.com/archives/
Go read through the Quake 3 source code to learn about how to structure a large codebase in C for realtime apps (look especially at how the game engine is separated and traps the syscalls made by the game logic: https://github.com/id-Software/Quake-III-Arena https://github.com/id-Software/Quake-III-Arena
The Linux kernel has some expert-level macro usage and organization as well.
~
I've cited a lot of game code here, because that's what's probably most accessible, and is where I cut my teeth doing stupid things and learning. There are doubtless better places (especially for best practices), but I think that open game code is a good starting point.
EDIT:
Dr. Dobb's had a good writeup on the unit testing stuff:
http://www.drdobbs.com/testing/unit-testing-in-c-tools-and-conventions/240156344 http://www.drdobbs.com/testing/unit-testing-in-c-tools-and-c...
That's a bit different from how we've solved it in the past, but still good!