Recently I am working on modifying a middle scale windows program. Aim is to make it cross platform (linux/win) and since I have written every single line of over 100000 lines, I have no one to blame. Much of the work is done (opposed to my initial guess) fairly easily, just simple #ifdefs and some wrapper code. One of more or less interesting problem is presented below,
vim /usr/include/c++/4.7/limits line 313
So problem should be about
macro max() contradiction. System one is from file limits, but where is the other? I never use lowercase in naming anything other than variables. Let’s
grep to find.
grep max * -R
Other end of contradiction is due to ITU-T G729 reference code. Now let’s try to resolve this. Omitted namespace restriction is another shame but won’t help here because the problem comes from
#define. Reordering headers in order to mask the one in g729 part may help in compilation but problem will probably reappear in link. With observation that max definition in g729 only used once, let’s rename it to another meaningful name MAX_OF_TWO to solve the problem.
Result of fix may be checked with recompilation.