I\'m developing optimizations for my 3D calculations and I now have:
plain\" version using the standard C language libraries,
One way is to implement three libraries conforming to the same interface. With dynamic libraries, you can just swap the library file and the executable will use whatever it finds. For example on Windows, you could compile three DLLs:
And then make the executable link against Impl.dll. Now just put one of the three specific DLLs into the same directory as the .exe, rename it to Impl.dll, and it will use that version. The same principle should basically be applicable on a UNIX-like OS.
The next step would be to load the libraries programmatically, which is probably the most flexible, but it is OS specific and requires some more work (like opening the library, obtaining function pointers etc.)
Edit: But of course, you could just implement the function three times and select one at runtime, depending on some parameter/config file setting etc., as lined out in the other answers.