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

DebugBreak name clash on MSVC #12

Closed
jalfd opened this issue Feb 15, 2011 · 2 comments
Closed

DebugBreak name clash on MSVC #12

jalfd opened this issue Feb 15, 2011 · 2 comments

Comments

@jalfd
Copy link

jalfd commented Feb 15, 2011

When compiled under MSVC, the code fails if windows.h is included.

That header defines a function DebugBreak() while CATCH checks for a macro with the same name.

On a related note, on MSVC, the intrinsic __debugbreak() should be preferred over DebugBreak() (the latter requires windows.h, and requires debug symbols or it'll break into the wrong stack frame)

Here's a quick MSVC DebugBreak() replacement I whipped up:

#if defined(_MSC_VER)
    extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
    #define DebugBreak() if (IsDebuggerPresent() ) { __debugbreak(); }
#endif

(Still kind of ugly to reuse the name DebugBreak though. Would be cleaner to rename it entirely to avoid conflicting with the windows.h one)

@philsquared
Copy link
Collaborator

Thanks for bringing this up.
Oddly I just started seeing this in the VS2010 solution I have running in my EC2 instance - but I haven't had any time where I have access to sufficient internet access to fix it :-(
I'll be trying to reproduce it in my VM on my laptop. Hope to have a fix shortly.

@philsquared
Copy link
Collaborator

Should be fixed now. I used your suggestion more-or-less as-is. Thanks for that.
I also renamed the top level macro to avoid the name clash (which makes more sense now we're using __debugbreak() ).

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants