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 - SDL appears to use enums instead of enum classes
Summary: SDL appears to use enums instead of enum classes
Status: WAITING
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: 2.0.9
Hardware: x86 Windows 10
: P2 trivial
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-19 19:07 UTC by Alex
Modified: 2020-05-28 22:36 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.