Thanks Tim!

I didn’t know about C++ variable length arrays.  That makes perfect sense now.

Looks like people have been requesting Visual Studio add support for VLAs; 
there are no indications they will be supported.

From: thor...@apple.com <thor...@apple.com>
Sent: Thursday, January 17, 2019 3:50 PM
To: Salisbury, Mark <mark.salisb...@hp.com>
Cc: webkit-dev@lists.webkit.org
Subject: Re: [webkit-dev] Compile error in WebGL2RenderingContext.cpp




On Jan 16, 2019, at 20:56, Salisbury, Mark 
<mark.salisb...@hp.com<mailto:mark.salisb...@hp.com>> wrote:

Hello,

Hello!


I’m working on rebasing our downstream webkit port; I just pulled down recent 
webkit changes (since July ’18) and I hit a piece of code that’s failing to 
compile in Visual Studio 2017.  When I look at the code however, I’m not sure 
how it compiles on any compiler, or if it compiles, how it’s safe.

This is from Source/WebCore/html/canvas/WebGL2RenderingContext.cpp -

…
    int numValues = 0;
#if USE(OPENGL_ES)
    m_context->getInternalformativ(target, internalformat, 
GraphicsContext3D::NUM_SAMPLE_COUNTS, 1, &numValues);

    GC3Dint params[numValues];
    m_context->getInternalformativ(target, internalformat, pname, numValues, 
params);
#else
    // On desktop OpenGL 4.1 or below we must emulate glGetInternalformativ.

Visual Studio doesn’t like it because it won’t instantiate an array without a 
const size.  On the other hand, even if it compiled, passing an array with 0 
size doesn’t make a lot of sense, to receive parameters back, which appears to 
be the intent of the code.

Why do you think it would be 0?

numValues is passed as an out arg in the first getInternalformativ call, and is 
presumably filled with the value for the key NUM_SAMPLE_COUNTS.

That said, this depends on a C99 feature that is maybe only available as a 
compiler extension in C++ and it sounds like isn't supported by the VS compiler 
("variable length arrays"). So I'm guessing nobody has built it with VS yet.



The file is associated with WebGL2, but it’s added to the build in the 
ENABLE_WEBGL block in WebCore/CMakeLists.txt.
WEBGL2 is off by default (per WebKitFeatures.cmake) so I assume the code could 
not be invoked without enabling WEBGL 2.

The contents of this file are guarded with #if ENABLE(WEBGL2); you should 
probably figure out why that's turned on if you don't expect it.


Am I looking at unfinished code that magically compiles with gcc/llvm/etc. (non 
Visual Studio)?

Thanks,
Mark




_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org<mailto:webkit-dev@lists.webkit.org>
https://lists.webkit.org/mailman/listinfo/webkit-dev<https://lists.webkit.org/mailman/listinfo/webkit-dev>

_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev

Reply via email to