Export (0) Print
Expand All
Expand Minimize
0 out of 1 rated this helpful - Rate this topic

Compiler Error C3068

Error Message

'function' : a 'naked' function cannot contain objects that would require unwinding if a C++ exception occurred

The compiler was unable to perform stack unwinding on a naked function that threw an exception because a temporary object was created in the function and C++ exception handling (/EHsc) was specified.

To resolve this error, do at least one of the following:

  • Do not compile with /EHsc.

  • Do not mark the function as naked.

  • Do not create a temporary object in the function.

If a function creates a temporary object on the stack, if the function throws an exception, and if C++ exception handling is enabled, the compiler will clean up the stack if an exception is thrown.

When an exception is thrown, compiler generated code, called the prolog and epilog and which are not present in a naked function, is executed for a function.


The following sample generates C3068:

// C3068.cpp
// compile with: /EHsc
// processor: x86
class A {

void b(A){}

__declspec(naked) void c() {
   b(A());   // C3068 
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.