Search code examples
directxhlsl

Can you emit warnings in HLSL?


Is it possible to emit warnings in HLSL? If so, how?
I know there's #error keyword in HLSL to emit errors like:

#ifndef PI
#error "PI is not defined"
#endif

But I want to do something like this:

#if !defined(MAX_SIZE)
#warning "Max size is not defined, defaulting to 1024"
#define MAX_SIZE 1024
#endif

Solution

  • There is no specific macro for warning.

    However, something like that can work for you.

    #pragma message "Warning: Max size is not defined, defaulting to 1024"
    

    More details here.