4

I am currently working on a embedded C project and I "inherited" some old code containing statements such as:

rxStruct = rxStruct;

where rxStruct is a variable.

What could be the use of such statements?

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • 9
    It could have something to do with memory mapped device I/O. Context is important here, nobody can guess at this from a single line of code. – Hans Passant Aug 27 '12 at 12:39
  • Could also be a crude way to add code/instructions to break on. I.e. act as place to set a breakpoint. I’ve seen that in colleagues’ code. Hans’ suggestion is also very plausible. – Morten Jensen Mar 19 '23 at 10:39

1 Answers1

15

Without further information, one use of such a statement is to prevent an unused parameter compiler warning if rxStruct is passed in as a parameter and then otherwise not used.

acraig5075
  • 10,588
  • 3
  • 31
  • 50
  • 3
    A better way to do it: `(void)rxStruct`. Usually you should use a define: `#define UNUSED(X) (void)X`. – Gui13 Aug 27 '12 at 13:08