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

MS-compatibility: XAudio2.h fails to compile due to spaces in GUID #23445

Closed
llvmbot opened this issue Mar 30, 2015 · 7 comments
Closed

MS-compatibility: XAudio2.h fails to compile due to spaces in GUID #23445

llvmbot opened this issue Mar 30, 2015 · 7 comments
Labels
bugzilla Issues migrated from bugzilla clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 30, 2015

Bugzilla Link 23071
Resolution FIXED
Resolved on Apr 17, 2015 07:51
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @rnk

Extended Description

The following code (excerpted from Microsoft's DirectX header XAudio2.h) fails to compile with Windows compatibility:

#define DECLSPEC_UUID_WRAPPER(x) __declspec(uuid(#x))

#define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
class DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) className

DEFINE_CLSID(XAudio2, 5a508685, a254, 4fba, 9b, 82, 9a, 24, b0, 03, 06, af);
//DEFINE_CLSID(XAudio2,5a508685,a254,4fba,9b,82,9a,24,b0,03,06,af);

This results in:

% clang++ -fms-extensions -Wno-invalid-token-paste -c clang.cpp
clang.cpp:6:1: error: uuid attribute contains a malformed GUID
DEFINE_CLSID(XAudio2, 5a508685, a254, 4fba, 9b, 82, 9a, 24, b0, 03, 06, af);
^
clang.cpp:4:8: note: expanded from macro 'DEFINE_CLSID'
class DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) className
^
clang.cpp:1:50: note: expanded from macro 'DECLSPEC_UUID_WRAPPER'
#define DECLSPEC_UUID_WRAPPER(x) __declspec(uuid(#x))
^
:16:1: note: expanded from here
"5a508685- a254- 4fba- 9b82- 9a24b00306af"
^
1 error generated.

When using the commented DEFINE_CLSID-line without the spaces, the code compiles successfully.

@rnk
Copy link
Collaborator

rnk commented Mar 30, 2015

Yeah, I see the issue.

I can't find this GUID in the Win 7.0A SDK, the Win 8.0 SDK, or the Win 8.1 SDK. Where exactly did you encounter this issue? I don't want to add another compatibility hack unless it's a bug in a recent, widely used header.

@rnk
Copy link
Collaborator

rnk commented Mar 30, 2015

If this is just a problem in the 2010 June Direct X SDK, then I'd rather encourage people to migrate to the Win8 SDK than add this hack. The xaudio2.h header in the Win 8 SDK doesn't appear to have this problem.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Mar 30, 2015

Where exactly did you encounter this issue?

In the copy of the DirectX headers in the Unreal Engine which seem to be the June 2010 SDK. I noticed that a recent commit there included a workaround for clang's behavior[*] and thought I'd file a bug report.

[*] https://github.com/EpicGames/UnrealEngine/commit/701ad40823134d909081d70e83dea3a149a355ed (I'm afraid it's a private repository; you'll need to register an account at Epic Games to get access)

@llvmbot
Copy link
Collaborator Author

llvmbot commented Mar 30, 2015

Hey this is Mike Fricker at Epic.

I've been tracking the progress of Clang on Windows and updating Unreal Engine to support that as a build target as a background project. As of last weekend the Unreal Editor is now able to be fully compiled on Windows under Clang (requires LLVM r231657.)

Upgrading to a newer DirectX SDK is not really an option. There are a slew of PC titles that use the June 2010 DirectX SDK specifically for DirectX 9 support on Windows XP and Windows 7, which is not available in the newer SDKs.

The Unreal Engine codebase is actually an excellent test case for LLVM on all platforms. There are actually a number of other issues we've observed and can reproduce. I'll work with the team to get those entered into your database.

--Mike

@llvmbot
Copy link
Collaborator Author

llvmbot commented Mar 30, 2015

Honestly I would have thought that leading and trailing spaces were trimmed from arguments during macro expansion.

Another thing: This location in the preprocessor backtrace looks a bit weird:

| :16:1

I'll work with the team to get those entered into your database.

Please do!

@rnk
Copy link
Collaborator

rnk commented Mar 30, 2015

OK, if the June 2010 SDK is still super widely used, then we probably want to do something here.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Apr 17, 2015

Fixed by r235186: [MSVC] Mimic MSVC whitespace collapse for incompatible token pasting

The workaround is simple but a little ugly. Let me know if there's any fallout.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

2 participants