Skip to content

Fix the "unused function" warning caused by UuidStrHash - #2848

Merged
Ehsan (ehsannas) merged 2 commits into
microsoft:masterfrom
gongminmin:mgong/FixUuidStrHash
Apr 25, 2020
Merged

Ehsan (ehsannas) merged 2 commits into
microsoft:masterfrom
gongminmin:mgong/FixUuidStrHash

Conversation

@gongminmin

@gongminmin Minmin Gong (gongminmin) commented Apr 24, 2020 •

Copy link
Copy Markdown
Contributor

Move the declaration of UuidStrHash into #ifdef __EMULATE_UUID/#endif, and move its implementation to WinAdapter.cpp.

@gongminmin

Copy link
Copy Markdown
Contributor Author

Don't know why it still complaining about unused function on Linux GCC...

@AppVeyorBot

Copy link
Copy Markdown

@ehsannas Ehsan (ehsannas) added the linux Linux-specific work label Apr 24, 2020
@ehsannas

Copy link
Copy Markdown
Contributor

I applaud what you're doing.
These warnings are annoying and should be fixed. Would it be possible not to define the UuidStrHash function at all when __EMULATE_UUID is false? (rather than ignoring the -Wunused-function flag)

@ehsannas
Ehsan (ehsannas) self-requested a review April 24, 2020 15:33
@pow2clk

Copy link
Copy Markdown
Collaborator

I didn't see the original version of this that I suspect matches the title better which likely did what Ehsan is suggesting, just moving the #ifdef a few lines up to encompass UuindStrHash. The reason that didn't work is because this is a static function in a header file. So every file, whether they use DEFINE_CROSS_PLATFORM_UUIDOF or not, is receiving its own copy of that function. Any file that doesn't use its copy will produce the warning.

There are a couple ways you might fix this. You could make the function non-static and define it in WinAdapter.cpp when ___EMULATE_UUID is defined. Or you could convert it to a macro itself. I suspect the former will be easier.

@gongminmin

Copy link
Copy Markdown
Contributor Author

Gregory Roth (@pow2clk) and Ehsan (@ehsannas) , thanks for your advises. I just pushed a change based on your suggestion, move UuidStrHash() to WinAdapter.cpp. The warning get fixed by doing this.

@AppVeyorBot

Copy link
Copy Markdown

@gongminmin Minmin Gong (gongminmin) changed the title Move UuidStrHash into __EMULATE_UUID Fix the "unused function" warning caused by UuidStrHash Apr 25, 2020

@pow2clk Gregory Roth (pow2clk) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! thanks!

@ehsannas
Ehsan (ehsannas) merged commit 002ed97 into microsoft:master Apr 25, 2020
@gongminmin
Minmin Gong (gongminmin) deleted the mgong/FixUuidStrHash branch May 9, 2020 00:06
Marijn Suijten (MarijnS95) added a commit to MarijnS95/DirectXShaderCompiler that referenced this pull request Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linux Linux-specific work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants