This repository was archived by the owner on Dec 29, 2022. It is now read-only.
Repository navigation
[linux-port] Fix a handful of warnings in headers - #192
Merged
Merged
Conversation
Just a few warning conditions in a handful of common headers was producing pages and pages of warning messages. By fixing them, the output spew is reduced significantly. Static variables in a header produce a separate variable for every file that includes it. In many of these, these variables were unused. Instead, variables used in multiple files should be defined only once in a source file and declared as extern in the header. The implementation of DXASSERT for non-MS platforms in Global.h included a character array as part of the assert conditional which is always true, producing a warning. Furthermore, I don't think this would do what was expected as it would present no string. Instead, the message is printed out and an assert is raised. Many unsigned variables were checked to be greater than zero and less than 3 in HlslTypes.h. If they were somehow assigned a negative value, it would appear as much greater than 3 in unsigned form. So we can just check that they are less than or equal to 3. In Type.h, parammods_begin() was casting its return value to the proper pointer, but without const, producing an error. The best part is that the function returned a const pointer. The cast was just wrong. Adding const silences the warning. Facilitates google#184
ehsannas
approved these changes
May 18, 2018
| static const char* kFP32DenormKindString = "fp32-denorm-mode"; | ||
| static const char* kFP32DenormValueAnyString = "any"; | ||
| static const char* kFP32DenormValuePreserveString = "preserve"; | ||
| static const char* kFP32DenormValueFtzString = "ftz"; |
There was a problem hiding this comment.
Happy to see the removal of static pointer from header file.
| #define DXASSERT_LOCALVAR(local, exp, msg) DXASSERT(exp, msg) | ||
| #define DXVERIFY_NOMSG assert | ||
| #define DXASSERT(expr, fmt, ...) do { if (!(expr)) { char msg[80]; sprintf(msg, fmt, ##__VA_ARGS__); assert(false && msg); } } while (0); | ||
| #define DXASSERT(expr, fmt, ...) do { if (!(expr)) { fprintf(stderr, fmt, ##__VA_ARGS__); assert(false); } } while (0); |
There was a problem hiding this comment.
+1. I had run into this before and forgot to fix it. Before your fix, the assertion failure would print on screen as:
assertion failed: false && msg
:)
Author
|
build timed out. They seem to do that now and then. I don't think it has to do with the change. |
|
✅ Build DirectXShaderCompiler 1.0.50 completed (commit 478169b4f1 by @pow2clk) |
|
Awesome stuff! |
35 of 38 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Just a few warning conditions in a handful of common headers
was producing pages and pages of warning messages. By fixing them,
the output spew is reduced significantly.
Static variables in a header produce a separate variable for every
file that includes it. In many of these, these variables were unused.
Instead, variables used in multiple files should be defined only
once in a source file and declared as extern in the header.
The implementation of DXASSERT for non-MS platforms in Global.h
included a character array as part of the assert conditional
which is always true, producing a warning. Furthermore, I don't
think this would do what was expected as it would present no
string. Instead, the message is printed out and an assert is raised.
Many unsigned variables were checked to be greater than zero and less
than 3 in HlslTypes.h. If they were somehow assigned a negative
value, it would appear as much greater than 3 in unsigned form.
So we can just check that they are less than or equal to 3.
In Type.h, parammods_begin() was casting its return value to the
proper pointer, but without const, producing an error. The best
part is that the function returned a const pointer. The cast was
just wrong. Adding const silences the warning.
Facilitates #184