The warning function also allows you to control which warnings
are actually printed to the screen. If the warning function
is called with a string argument that is either "on" or "off"
all warnings will be enabled or disabled.
It is also possible to enable and disable individual warnings through their string identifications. The following code will issue a warning
warning ("non-negative-variable",
"'a' must be non-negative. Setting 'a' to zero.");
while the following won't issue a warning
warning ("off", "non-negative-variable");
warning ("non-negative-variable",
"'a' must be non-negative. Setting 'a' to zero.");
The functions distributed with Octave can issue one of the following warnings.
Octave:abbreviated-property-matchOctave:abbreviated-property-match warning is enabled.
Octave:array-to-scalarOctave:array-to-scalar warning is enabled, Octave will
warn when an implicit conversion from an array to a scalar value is
attempted.
By default, the Octave:array-to-scalar warning is disabled.
Octave:array-to-vectorOctave:array-to-vector warning is enabled, Octave will
warn when an implicit conversion from an array to a vector value is
attempted.
By default, the Octave:array-to-vector warning is disabled.
Octave:assign-as-truth-valueOctave:assign-as-truth-value warning is
enabled, a warning is issued for statements like
if (s = t)
...
since such statements are not common, and it is likely that the intent was to write
if (s == t)
...
instead.
There are times when it is useful to write code that contains
assignments within the condition of a while or if
statement. For example, statements like
while (c = getc())
...
are common in C programming.
It is possible to avoid all warnings about such statements by
disabling the Octave:assign-as-truth-value warning,
but that may also let real errors like
if (x = 1) # intended to test (x == 1)!
...
slip by.
In such cases, it is possible suppress errors for specific statements by writing them with an extra set of parentheses. For example, writing the previous example as
while ((c = getc()))
...
will prevent the warning from being printed for this statement, while allowing Octave to warn about other assignments used in conditional contexts.
By default, the Octave:assign-as-truth-value warning is enabled.
Octave:associativity-changeOctave:associativity-change warning is
enabled, Octave will warn about possible changes in the meaning of
some code due to changes in associativity for some operators.
Associativity changes have typically been made for matlab
compatibility.
By default, the Octave:associativity-change warning is enabled.
Octave:autoload-relative-file-nameOctave:autoload-relative-file-name is enabled,
Octave will warn when parsing autoload() function calls with relative
paths to function files. This usually happens when using autoload()
calls in PKG_ADD files, when the PKG_ADD file is not in the same
directory as the .oct file referred to by the autoload() command.
By default, the Octave:autoload-relative-file-name warning is enabled.
Octave:broadcastOctave:built-in-variable-assignmentOctave:built-in-variable-assignment warning is
enabled.
Octave:divide-by-zeroOctave:divide-by-zero warning is enabled, a
warning is issued when Octave encounters a division by zero.
By default, the Octave:divide-by-zero warning is enabled.
Octave:fopen-file-in-pathOctave:fopen-file-in-path warning is enabled.
Octave:function-name-clashOctave:function-name-clash warning is enabled, a
warning is issued when Octave finds that the name of a function
defined in a function file differs from the name of the file. (If
the names disagree, the name declared inside the file is ignored.)
By default, the Octave:function-name-clash warning is enabled.
Octave:future-time-stampOctave:future-time-stamp warning is enabled, Octave
will print a warning if it finds a function file with a time stamp
that is in the future.
By default, the Octave:future-time-stamp warning is enabled.
Octave:glyph-renderOctave:glyph-render warning is enabled.
Octave:imag-to-realOctave:imag-to-real warning is enabled, a warning is
printed for implicit conversions of complex numbers to real numbers.
By default, the Octave:imag-to-real warning is disabled.
Octave:load-file-in-pathOctave:load-file-in-path warning is enabled.
Octave:logical-conversionOctave:logical-conversion warning is enabled.
Octave:matlab-incompatibleOctave:matlab-incompatible warning is disabled.
Octave:md5sum-file-in-pathOctave:md5sum-file-in-path warning is enabled.
Octave:missing-glyphOctave:missing-glyph warning is enabled.
Octave:missing-semicolonOctave:missing-semicolon warning is enabled, Octave
will warn when statements in function definitions don't end in
semicolons.
By default the Octave:missing-semicolon warning is disabled.
Octave:mixed-string-concatOctave:mixed-string-concat warning is enabled, print a
warning when concatenating a mixture of double and single quoted strings.
By default, the Octave:mixed-string-concat warning is disabled.
Octave:neg-dim-as-zeroOctave:neg-dim-as-zero warning is enabled, print a warning
for expressions like
eye (-1)
By default, the Octave:neg-dim-as-zero warning is disabled.
Octave:nested-functions-coercedOctave:nested-functions-coerced warning is enabled.
Octave:noninteger-range-as-indexOctave:noninteger-range-as-index warning is enabled.
Octave:num-to-strOctave:num-to-str warning is enable, a warning is
printed for implicit conversions of numbers to their ASCII character
equivalents when strings are constructed using a mixture of strings and
numbers in matrix notation. For example,
[ "f", 111, 111 ]
⇒ "foo"
elicits a warning if the Octave:num-to-str warning is
enabled. By default, the Octave:num-to-str warning is enabled.
Octave:possible-matlab-short-circuit-operatorOctave:possible-matlab-short-circuit-operator warning
is enabled, Octave will warn about using the not short circuiting
operators & and | inside if or while
conditions. They normally never short circuit, but matlab always
short circuits if any logical operators are used in a condition. You
can turn on the option
do_braindead_shortcircuit_evaluation(1)
if you would like to enable this short-circuit evaluation in
Octave. Note that the && and || operators always short
circuit in both Octave and matlab, so it's only necessary to
enable matlab-style short-circuiting it's too arduous to modify
existing code that relies on this behavior.
By default, the Octave:possible-matlab-short-circuit-operator warning
is enabled.
Octave:precedence-changeOctave:precedence-change warning is enabled, Octave
will warn about possible changes in the meaning of some code due to
changes in precedence for some operators. Precedence changes have
typically been made for matlab compatibility.
By default, the Octave:precedence-change warning is enabled.
Octave:recursive-path-searchOctave:recursive-path-search warning is enabled.
Octave:reload-forces-clearOctave:reload-forces-clear warning is enabled, Octave will
warn you when this happens, and print a list of the additional
functions that it is forced to clear.
By default, the Octave:reload-forces-clear warning is enabled.
Octave:resize-on-range-errorOctave:resize-on-range-error warning is enabled, print a
warning when a matrix is resized by an indexed assignment with
indices outside the current bounds.
By default, the ## Octave:resize-on-range-error warning is disabled.
Octave:separator-insertOctave:separator-insert warning is disabled.
Octave:shadowed-functionOctave:shadowed-function warning is enabled.
Octave:single-quote-stringOctave:single-quote-string warning is disabled.
Octave:singular-matrix-divOctave:singular-matrix-div warning is enabled.
Octave:sqrtm:SingularMatrixOctave:sqrtm:SingularMatrix warning is enabled.
Octave:str-to-numOctave:str-to-num warning is enabled, a warning is printed
for implicit conversions of strings to their numeric ASCII equivalents.
For example,
"abc" + 0
⇒ 97 98 99
elicits a warning if the Octave:str-to-num warning is enabled.
By default, the Octave:str-to-num warning is disabled.
Octave:undefined-return-valuesOctave:undefined-return-values warning is disabled,
print a warning if a function does not define all the values in
the return list which are expected.
By default, the Octave:undefined-return-values warning is enabled.
Octave:variable-switch-labelOctave:variable-switch-label warning is enabled, Octave
will print a warning if a switch label is not a constant or constant
expression.
By default, the Octave:variable-switch-label warning is disabled.