1
\$\begingroup\$

Say I am developing a Math library and I want it to be such that it will detect whether or not user's machine support SSE (and which version) and based on that, different functions will be called. I can think of three ways to implement that:

  1. Have global function pointers in the library and let user call mathInit() i their source. When they do, figure out the hardware details and assign the function pointers to different functions.

  2. Same, except instead of having global function pointers, put them in a struct which is returned by mathInit(). This way, user will have to call math.vec3Add(...) or similar.

  3. Same as 1, but instead of having global pointers, make mathInit() a macro so that the function pointers will have local scope in user's main() function (and require mathInit() to be called from main()).

Is any of these methods preferable? Is there some other, better way?

\$\endgroup\$

closed as off-topic by MichaelHouse Aug 21 '16 at 6:23

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions that aren't specific to game development are off-topic here, but can be asked on Stack Overflow. A good rule of thumb is to ask yourself "would a professional game developer give me a better/different/more specific answer to this question than other programmers?"" – MichaelHouse
If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.