Watcom FYI

I have been investigating why when converting a program from C to C++ the
executable become much bigger.

I discover the culprid to be option -Oe which is suppose to allow for
fonctions to be inlined automaticaly be the compiler. It’s also possible to
specify the criteria, size wise, that will allow for a fonction to be
inlined. The manual says the default is 20, but it appears that for the C++
compiler it closer to 100. That means a lot more fonctions will be inlined.

I actually got bitten hard by this in a recursive program (copy dir like),
where the last fonction that does the copy of the file allocated 16k on the
stack to read the data from the file in. That copy file fonction got
inlined into the CopyDir routine (which is recurse) hence for each level of
depth in the directory it was allocating 16k of stack, which was blowing the
stack, but the C version of the program did not…

There is also some discrepencies between the number passed to #pragma
inline_depth and -Oe=. That is the value of the #pragma need5 to be like 5
time smaller then the value of -Oe= to get the same results.

  • Mario