You've got a conditional tacked onto a my-declaration. This has rather unintuitive effects: it contructs a local static variable (in c-speak). This feature/bug is deprecated, and not what you want to do anyway, so you are safe to stick to your second version.