### #pragma leaves

Description

The #pragma leaves directive takes a function name, and specifies that the function never returns to the instruction following that function call.

Syntax

This pragma tells the compiler that the flow of the program's execution terminates when function is called.

The advantage of the pragma is that it allows the compiler to ignore any code that exists after function, in turn, the optimizer can generate more efficient code. This pragma is commonly used for custom error-handling functions, in which programs can be terminated if a certain error is encountered. Some functions which also behave similarily are exit, longjmp, and terminate.

Example

    #pragma leaves(handle_error_and_quit)
    void test_value(int value)
    {
    	if (value == ERROR_VALUE)
    	{
    		handle_error_and_quit(value);
    		TryAgain();	// optimizer ignores this because
    				// never returns to execute it
    	}
    }

Preprocessor Directives
C Language Levels

#pragma Preprocessor Directives
List of Preprocessor Directives