Compartilhar via


naked (Windows CE 5.0)

Send Feedback

The __declspec( naked ) extended storage-class modifier causes the compiler to generate code without a prolog or epilog.

__declspec( naked )declarator

You can use this feature to write your own prolog/epilog code sequences using inline assembler code.

Naked functions are particularly useful in writing virtual device drivers.

Because the naked attribute is only relevant to the definition of a function and is not a type modifier, naked functions must use extended attribute syntax and the __declspec keyword.

Examples

The following code example defines a function with the naked attribute:

__declspec( naked ) int func( formal_parameters )
{
  // Function body
}

Or, alternatively:

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

The naked attribute affects only the nature of the compiler code generation for the functions prolog and epilog sequences. It does not affect the code that is generated for calling such functions.

Thus, the naked attribute is not considered part of the function's type, and function pointers cannot have the naked attribute. Further, the naked attribute cannot be applied to a data definition.

The following code example generates an error:

__declspec( naked ) int i;       // Error--naked attribute not
                                 // permitted on data declarations.

The naked attribute is relevant only to the definition of the function and cannot be specified in the functions prototype. For example, the following declaration generates a compiler error:

__declspec( naked ) int func();  // Error--naked attribute not 
                                 // permitted on function declarations

See Also

__declspec

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.