What is #pragma used for?

前端 未结 2 1711
离开以前
离开以前 2020-12-14 07:42

Can anyone help me understand #pragma?

ifndef TARGET_OS_LINUX
#pragma once
endif

What,when, where, why, an example?

The above is in

相关标签:
2条回答
  • 2020-12-14 08:22
    • What -- it is header guard. This file will be included only once.
    • When -- at a compile process
    • why -- to avoid double including.

    "Header guards are little pieces of code that protect the contents of a header file from being included more than once."

    0 讨论(0)
  • 2020-12-14 08:27

    #pragma is just the prefix for a compiler-specific feature.

    In this case, #pragma once means that this header file will only ever be included once in a specific destination file. It removes the need for include guards.

    0 讨论(0)
提交回复
热议问题