-2

What is the mm## meant in C code? For example:

#define REGISTER(addr) *((volatile unsigned int *)(addr))

#define abc(reg)  REGISTER(mm##reg)
wovano
  • 4,543
  • 5
  • 22
  • 49
wxfx
  • 1
  • 1
    Look up "c preprocessor concatenate" – 001 Aug 25 '20 at 00:49
  • 1
    Does this answer your question? [Use of double hash (##) in C](https://stackoverflow.com/questions/15885213/use-of-double-hash-in-c) – wovano Aug 25 '20 at 07:13
  • In short: it replaces `abc(123)` by `REGISTER(mm123)`, which in turn is being replaced by `*((volatile unsigned int *)(mm123))`. – wovano Aug 25 '20 at 07:15

1 Answers1

0

Per the gcc docs:

The ‘##’ preprocessing operator performs token pasting. When a macro is expanded, the two tokens on either side of each ‘##’ operator are combined into a single token, which then replaces the ‘##’ and the two original tokens in the macro expansion. Usually both will be identifiers, or one will be an identifier and the other a preprocessing number. When pasted, they make a longer identifier. This isn’t the only valid case. It is also possible to concatenate two numbers (or a number and a name, such as 1.5 and e3) into a number. Also, multi-character operators such as += can be formed by token pasting.

In your case, it's creating a new identifier prefixed with the characters mm.

Lytigas
  • 904
  • 1
  • 7
  • 16