Search Unity

#include directive not properly stripped by #ifdef in shader in Unity 5.5.0 or lower

Discussion in 'Shaders' started by stephero, Dec 17, 2018.

  1. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    123
    Hi guys,

    I found a really weird behavior regarding include direction in shader code in older Unity version (5.5.0f3 or lower).

    The following shader code does NOT compile in Unity 5.5.0f3 or lower, but works perfectly fine in Unity 5.5.1f1 or higher:
    Code (CSharp):
    1. CGPROGRAM
    2.  
    3. // ...
    4.  
    5. //#define NOTDEFINED
    6.  
    7. #ifdef NOTDEFINED
    8. #include "InvalidIncludedFile"
    9. #endif
    10.  
    11. // ...
    12.  
    13. ENDCG
    In Unity 5.5.0f3 or lower, the #include directive is not properly stripped and is evaluated even if the mac NOTDEFINED is not defined...
    I looked in the 5.5.1f1 release note but couldn't find anything related to a fix regarding this.

    My question is: is there a way to make it work (properly strip #include directive) in Unity <= 5.5.0 ?

    Thanks