-
Notifications
You must be signed in to change notification settings - Fork 659
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
Argument macro expansion in token-pasting operator #1005
Comments
Interesting, I just recently run into this exact issue. But decided work around it since I could not find any documentation on how a HLSL preprocessor is expected to behave. |
I ran into this issue as well. We have a multiplatform engine that supports multiple languages. For constant buffers we have the following define:
which is used as follows: #define CB_INDEX 1 CONSTANT_BUFFER(Buffer, CB_INDEX) This fails because it will not replace CB_INDEX with 1. I have the following workaround that works:
|
The fxc compiler evaluates both operands before performing the token-pasting operation. But the default Clang way is to follow C standard, which token-pastes operands as-is, without any pre-expanding. This commit adds support for the fxc behavior via the command line option: -flegacy-macro-expansion. Fixes #1005
We now have the |
fxc and dxc have different behaviors when handling token-pasting operator (
##
). fxc does macro expansion on its arguments before concatenating, but dxc does not.For the following HLSL source code:
fxc accepts it but dxc rejects it.
I think dxc is just following clang's handling of token-pasting operator. In C, token-pasting operator arguments are not macro-expanded first:
http://en.cppreference.com/w/cpp/preprocessor/replace
https://msdn.microsoft.com/en-us/library/09dwwt6y.aspx
(
cl.exe /TC /DC_PROGRAM
rejects the above program.)Just wanted to raise this issue to see how we should proceed with this behavior mismatch. Do we want to mimic the fxc way in dxc?
The text was updated successfully, but these errors were encountered: