Why are empty expressions legal in C/C++?

后端 未结 11 1813
囚心锁ツ
囚心锁ツ 2020-11-29 11:21
int main()
{
  int var = 0;; // Typo which compiles just fine
}
11条回答
  •  抹茶落季
    2020-11-29 11:33

    while (1) {
        ;  /* do nothing */
    }
    

    There are times when you want to sit and do nothing. An event/interrupt driven embedded application or when you don't want a function to exit such as when setting up threads and waiting for the first context switch.

    example: http://lxr.linux.no/linux+v2.6.29/arch/m68k/mac/misc.c#L523

提交回复
热议问题