What is __declspec and when do I need to use it?

前端 未结 6 1183
耶瑟儿~
耶瑟儿~ 2020-11-30 18:08

I have seen instances of __declspec in the code that I am reading. What is it? And when would I need to use this construct?

6条回答
  •  借酒劲吻你
    2020-11-30 18:23

    Another example to illustrate the __declspec keyword:

    When you are writing a Windows Kernel Driver, sometimes you want to write your own prolog/epilog code sequences using inline assembler code, so you could declare your function with the naked attribute.

    __declspec( naked ) int func( formal_parameters ) {}
    

    Or

    #define Naked __declspec( naked )
    Naked int func( formal_parameters ) {}
    

    Please refer to naked (C++)

提交回复
热议问题