We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4867

Summary: SDL appears to use enums instead of enum classes
Product: SDL Reporter: Alex <alex>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: WAITING --- QA Contact: Sam Lantinga <slouken>
Severity: trivial    
Priority: P2    
Version: 2.0.9   
Hardware: x86   
OS: Windows 10   

Description Alex 2019-11-19 19:07:51 UTC
When I compile my code in Visual Studio, I get the following warnings:
Warning	C26812	The enum type 'SDL_Scancode' is unscoped. Prefer 'enum class' over 'enum'
and	
Warning	C26812	The enum type 'SDL_Bool' is unscoped. Prefer 'enum class' over 'enum'

The discussion at the bottom of the  MSDN page for this warning suggests that developers should report this as a bug in APIs, so here I am.
Comment 1 Sam Lantinga 2019-12-04 06:35:30 UTC
Maybe we need an SDL_ENUM definition that resolves to enum in C and enum class for C++ at the appropriate revision?

Alex, what version of Visual Studio are you running?
Comment 2 Alex 2019-12-04 16:53:58 UTC
I'm running what I believe to be the latest version: Visual Studio Community 2019 Version 16.3.9
Comment 3 Ryan C. Gordon 2019-12-04 19:23:02 UTC
(In reply to Alex from comment #0)
> The discussion at the bottom of the  MSDN page for this warning suggests
> that developers should report this as a bug in APIs, so here I am.

With respect to Microsoft, but this is _not_ a bug in external APIs, it's a C++-specific, overaggressive compiler warning about a common API pattern. We should probably just disable this warning within the scope of the SDL headers.

Also, if we make these into "enum class" types, it'll break unsuspecting C++11 programs that include SDL.h and then try to do...

   SDL_bool x;
   x = SDL_TRUE;

...as this would become a compiler error. It would need to be "x = SDL_bool::SDL_TRUE;"

--ryan.