简体   繁体   中英

Using Try/Catch with naked functions

Why using Try-Catch is not allowed with naked functions? And is there an alternative?

Error 2 error C2490: 'try' not allowed in function with 'naked' attribute   

Structured Exception Handling and C++ Exception Handling constructs are not permitted because they must unwind across the stack frame.

(see this link from the same site as above )

The reason it doesn't work to use exception handling over "naked" is that they functions don't have the standard prolog and epilog parts, which is necessary for "unwinding of the stack", which "catch" does. It says so here (limitations of naked functions).

You will need to find some other way to achieve what you want - either wrap your naked functions some way that "makes them dressed"[dressed = opposite of naked, not sure if that is the technical term] or don't use try-catch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM