Project

General

Profile

Design #1628

Unused variables, params, data members

Added by John Abbott over 2 years ago. Updated about 1 year ago.

Status:
In Progress
Priority:
Normal
Assignee:
-
Category:
Tidying
Target version:
Start date:
03 Nov 2021
Due date:
% Done:

10%

Estimated time:
Spent time:

Description

Anna reports that clang issues warning about unused data-members (in MatrixFpNonRed).
The data-members are used when debugging is active, but not otherwise.
How best to implement this (and keep good readability)?

History

#1 Updated by John Abbott over 2 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

clang is probably correct to report that the data-members are unused.
Their presence makes objects of this class needlessly large.

How to express this neatly in the source code?
Note that several places need to be modified.

#2 Updated by John Abbott over 2 years ago

The KISS solution would be to use the CoCoA_DEBUG macro.
I'm not keen to use macros (esp. to make #ifdef blocks of code).

#3 Updated by John Abbott over 2 years ago

I have just implemented the KISS approach: namely 2 #ifdef blocks. Everything compiles, & all tests pass (both with and without debugging).

I now think that this KISS approach is OK for the current situation.
But if we encounter future similar situations then maybe a "more sophisticated" approach is warranted.

There are some suggestions at https://stackoverflow.com/questions/1486904/how-do-i-best-silence-a-warning-about-unused-variables

#4 Updated by John Abbott over 2 years ago

  • Target version changed from CoCoALib-0.99800 to CoCoALib-0.99850

I tried changing CoCoA_ASSERT so that it expanded to (void)sizeof(cond), BUT this worked badly because some assertions needed fns which are included only if CoCoA_DEBUG is defined (the include was inside an ifdef block). So I reverted to the old solution: namely empty.

Anna suggest maybe a macro something like *IF_DEBUG(code) which expands to nothing when debugging is off, and otherwise expands to code.

We shall postpone this issue to next version.

#5 Updated by John Abbott about 1 year ago

  • Target version changed from CoCoALib-0.99850 to CoCoALib-0.99880

#6 Updated by John Abbott about 1 year ago

Several functions have an unused parameter CheckForTimeout.
It would be nice to activate the time-out for these fns.
Can we do this for the upcoming release?

Also available in: Atom PDF