Why do multi-line macros have backslashes at the end of each line?

后端 未结 4 1507

In a macro declaration like:

#define WAIT_SPI2_TRANSMISSON_END() {while ((SPI2_SR & SPI_SR_TXCTR_MASK) != 0) {\\
                                     if(         


        
4条回答
  •  一个人的身影
    2020-12-31 05:23

    It's a line continuation character.

    There should be nothing else after it (aside from an end of line character), including white space.

    It's particularly useful for macros as it adds clarity.

    (Very, very occasionally - especially in old code - you'll see the trigraph sequence ??/ in place of \. These days though it's more of an interviewers' trick question.)

提交回复
热议问题