Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support __LINE__ macro for the caller of a macro #3940

Closed
swoods-nv opened this issue Apr 12, 2024 · 3 comments · Fixed by #3942
Closed

Support __LINE__ macro for the caller of a macro #3940

swoods-nv opened this issue Apr 12, 2024 · 3 comments · Fixed by #3942
Assignees
Labels
goal:client support Feature or fix needed for a current slang user.

Comments

@swoods-nv
Copy link
Collaborator

swoods-nv commented Apr 12, 2024

[Posted on behalf of a user without GH account]

We are using the __LINE__ macro in combination with GPU printing to implement an assert in shader code. The assert roughly looks like this:

#define STR2(X) # X
#define STR(X) STR2(X)
#define CARB_ASSERT(X) \                     //<-- let's say this is line 100 in our file
if (!(X)) { \
        println_assert("Assertion triggered in " __FILE__ ":" STR(__LINE__) ", expression : " #X); \
}

this assert is used just as expected

void main(dispatchIdx...)
{
    float3 radiance = compute();
    CARB_ASSERT(!isNanOrInf(radiance)); ///< will show line 100 from different file, not this line
}

I browsed tests\preprocessor\special-macro-complex.slang but didn't find a matching test for it. I did find this comment which shows the usage of LINE in a macro but probably expects a different result:

// LINE number will be for the macro invocation, not the expansion
@swoods-nv swoods-nv added the goal:client support Feature or fix needed for a current slang user. label Apr 12, 2024
@swoods-nv swoods-nv added this to the Q2 2024 (Spring) milestone Apr 12, 2024
@csyonghe
Copy link
Collaborator

This is duplicate with #2134

@swoods-nv
Copy link
Collaborator Author

Should we raise the priority / pull it in to Q2, in that case? It affects a current client, but they have a workaround.

@csyonghe
Copy link
Collaborator

Yes, we can try to fix this in Q2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal:client support Feature or fix needed for a current slang user.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants