Use of #pragma in C

前端 未结 10 1783
囚心锁ツ
囚心锁ツ 2020-11-27 09:32

What are some uses of #pragma in C, with examples?

10条回答
  •  再見小時候
    2020-11-27 09:58

    Putting #pragma once at the top of your header file will ensure that it is only included once. Note that #pragma once is not standard C99, but supported by most modern compilers.

    An alternative is to use include guards (e.g. #ifndef MY_FILE #define MY_FILE ... #endif /* MY_FILE */)

提交回复
热议问题