I understand using the NETFX_CORE directive, like this:
#if NETFX_CORE
// Windows 8
#else
// Windows Phone 8
#endif
More info: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj714084(v=vs.105).aspx
But is there a directive specific to Windows Phone 8?
Yes, the Windows Phone directive is:
#if WINDOWS_PHONE
This is documented here, but I'm surprised that it isn't mentioned here. I also tested this in some code, and it works.