So, you're telling me that C++, a powerful programming language that's
powering operating systems and state-of-the-art games, isn't powerful enough
to define a simple conditional statement? Even a shell script (dash) can do
this:
#!/bin/sh
which kchmviewer > /dev/null
if [ $? = 0 ]
then # "which kchmviewer" exit code 0
USE_KCHMVIEWER=1
else # "which kchmviewer" exit code 1
USE_KCHMVIEWER=
fi
if [ "$USE_KCHMVIEWER" = '' ]
then
echo kchmviewer IS NOT installed.
else
echo kchmviewer IS installed.
fi
USE_KCHMVIEWER is not used in the code, however, I would like to replace
VBOX_OSE with it in the mentioned cases.
What do you mean by that USE_KCHMVIEWER isn't a variable? I understand that
VBOX_OSE (some of whose occurrences I want to replace with USE_KCHMVIEWER) is
a compile-time option. Now, I just want to create a code that could define
this at run-time instead of compile-time, and then put it somewhere into the
codebase. The expected result should be that whenever I access the
documentation inside the GUI, either the CHM or PDF file will be opened based
on what document viewer is available at the moment (kind of a OSE/non-OSE
hybrid).
So you're basically saying that variables (or whatever USE_KCHMVIEWER is)
used in preprocessor statements (the lines with a hashtag) cannot be
changed/redefined once the program is compiled because they are replaced by
their value (i.e. they are hardcoded). What would be the preferred way to
work around this (i.e. what should I use instead of # ifdef USE_KCHMVIEWER,
and # if !defined USE_KCHMVIEWER)?