Yes, on my 64-bit build on linux (32-bit architecture) I'd have to use your solution.
On an architecture where sizeof(long)==8, I would think that neither solution would work. (This is probably, though not necessarily, an irrelevant observation in the context of what the op needs :-)