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 3776

Summary: link fails with SDL_windowsopengl.c
Product: SDL Reporter: Ozkan Sezer <sezeroz>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus
Version: HG 2.0   
Hardware: All   
OS: Windows (All)   
Attachments: memset avoidance patch for SDL_windowsopengl.c

Description Ozkan Sezer 2017-08-25 10:01:48 UTC
Created attachment 2892 [details]
memset avoidance patch for SDL_windowsopengl.c

With VS2005 when building for x64 (didn't try other MSVC versions):
1>SDL_windowsopengl.obj : error LNK2019: unresolved external symbol memset referenced in function WIN_GL_CreateContext

If I remove the 0 terminator from attribs[15] array (because you're
already adding it later) then it is good, but this time win32 fails
the same way instead.

My solution is changing it like the following, which works for both
x86 and x64:

--- SDL2/src/video/windows/SDL_windowsopengl.c.orig
+++ SDL2/src/video/windows/SDL_windowsopengl.c
@@ -727,16 +727,19 @@ WIN_GL_CreateContext(_THIS, SDL_Window *
         if (!wglCreateContextAttribsARB) {
             SDL_SetError("GL 3.x is not supported");
             context = temp_context;
         } else {
         /* max 14 attributes plus terminator */
-            int attribs[15] = {
-                WGL_CONTEXT_MAJOR_VERSION_ARB, _this->gl_config.major_version,
-                WGL_CONTEXT_MINOR_VERSION_ARB, _this->gl_config.minor_version,
-                0
-            };
-            int iattr = 4;
+            int attribs[15];
+            int iattr;
+
+            attribs[0] = WGL_CONTEXT_MAJOR_VERSION_ARB;
+            attribs[1] = _this->gl_config.major_version;
+            attribs[2] = WGL_CONTEXT_MINOR_VERSION_ARB;
+            attribs[3] = _this->gl_config.minor_version;
+
+            iattr = 4;
 
             /* SDL profile bits match WGL profile bits */
             if (_this->gl_config.profile_mask != 0) {
                 attribs[iattr++] = WGL_CONTEXT_PROFILE_MASK_ARB;
                 attribs[iattr++] = _this->gl_config.profile_mask;
Comment 1 Ozkan Sezer 2017-08-25 19:45:17 UTC
http://hg.libsdl.org/SDL/rev/9e5dc03870e1 fixed this.
Comment 2 Ryan C. Gordon 2017-08-25 20:35:49 UTC
Resolving.