Use of #pragma in C

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

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

10条回答
  •  攒了一身酷
    2020-11-27 10:10

    #pragma is used to do something implementation-specific in C, i.e. be pragmatic for the current context rather than ideologically dogmatic.

    The one I regularly use is #pragma pack(1) where I'm trying to squeeze more out of my memory space on embedded solutions, with arrays of structures that would otherwise end up with 8 byte alignment.

    Pity we don't have a #dogma yet. That would be fun ;)

提交回复
热议问题