We recommend using Visual Studio 2017

__getcallerseflags

 

The latest version of this topic can be found at __getcallerseflags.

Microsoft Specific**

Returns the EFLAGS value from the caller's context.

unsigned int __getcallerseflags(void);  

EFLAGS value from the caller's context.

IntrinsicArchitecture
__getcallerseflagsx86, x64

Header file <intrin.h>

This routine is only available as an intrinsic.

// getcallerseflags.cpp  
// processor: x86, x64  
  
#include <stdio.h>  
#include <intrin.h>  
  
#pragma intrinsic(__getcallerseflags)  
  
unsigned int g()  
{  
    unsigned int EFLAGS = __getcallerseflags();  
    printf_s("EFLAGS 0x%x\n", EFLAGS);  
    return EFLAGS;  
}  
unsigned int f()  
{  
    return g();  
}  
  
int main()  
{  
    unsigned int i;  
    i = f();  
    i = g();  
    return 0;  
}  

EFLAGS 0x202  
EFLAGS 0x206  

Compiler Intrinsics

Show: