octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Common gripe for unavailable functions when library does not exist


From: Rik
Subject: Common gripe for unavailable functions when library does not exist
Date: Fri, 15 Jan 2016 11:42:23 -0800

1/15/16

jwe,

How should we handle functions, principally dynamically linked ones, that
may not exist for a given installation of Octave?

Currently we have at least three strategies.

Strategy 1) #ifdef/code/#else/error (...)/#endif.

See dldfcn/amd.cc for example.

Strategy 2) #ifdef/code/#else/gripe/#endif.

See __glpk__.cc which uses gripe_not_supported.
See __magick_read__.cc which uses gripe_disabled_feature

Strategy 3) Declare macro that expands to error message and use that in
place of error or gripe.

See audiodevinfo.cc which has

#define NO_PORTAUDIO_MSG \
  error ("portaudio not found on your system and thus audio functionality
is not present"); \
  (void) args;  /* silence compiler warning "unused parameter" */

It seems like there should be a common response to the same situation which
says to me that a single gripe_XXX function should be made to handle all of
these cases.

A second issue is whether we want to suppress the warning messages about
the unused variable "args" when the DEFUN_DLD macro is used and the library
is not supported.  It is annoying to see these messages.  On the other
hand, the obvious way to suppress them leads to code bloat.

#ifdef HAVE_AMD
DEFUN_DLD (amd, args, nargout,
#else
DEFUN_DLD (amd, /* args */, nargout,
#endif

Or we could have something like what Mike did with a compiler trick to
silence the warning

(void) args;

but I have to say that even with the comment I was sort of confused as to
what was going on here.

The GNU coding standards (http://www.gnu.org/prep/standards/standards.html)
suggest not going to great lengths:

"Don’t make the program ugly just to placate static analysis tools such as
lint, clang, and GCC with extra warnings options such as -Wconversion and
-Wundef. These tools can help find bugs and unclear code, but they can also
generate so many false alarms that it hurts readability to silence them
with unnecessary casts, wrappers, and other complications. For example,
please don’t insert casts to void or calls to do-nothing functions merely
to pacify a lint checker."

So is the extra #ifdef around the DEFUN_DLD worth it or not?

--Rik




reply via email to

[Prev in Thread] Current Thread [Next in Thread]