This is a strange problem, so I have to provide a little background. I have a C ++ project I'm working on and want to clean up a bit. The main problem I'm dealing with makes me want to prohibit the massive abuse of the preprocessor macros that are used in the main component of the project. There is a file with a bunch #definethat is commented / uncommented before compiling and using the program to switch the use of different algorithms. I would prefer to use command line arguments rather than recompiling every time we want to try a different algorithm. The problem is that there is so much in the whole code #ifdefthat it seems impossible to simply reorganize the code for each algorithm.
I was told that the reason for this is that it must be a real-time system that will deal with millisecond time units, and the code in this component is called so many times that ifchecking will negatively affect our performance. If you want to try a different algorithm, you must set the appropriate flags and recompile to optimize performance.
So my question for all of you is this:
<i>
Is there a way to get rid of these macros and instead use command line arguments without a serious hit on performance and without altering the logic and code?
One of the options that I considered was an attempt to compile versions of this component for each of the possible combinations of algorithms, and then select the version that will be determined by the combination of the provided command line arguments. But, according to my friend, the number of combinations is too large to be feasible. I myself have not worked out these numbers, but I will take his word for it, given how much work he has contributed to this code.
source
share