Skip to main content
Up and Coming
January 24, 2015

Oculus, please keep C++ syntax out of the C SDK.

I recently ported my code to 0.4.4, and I noticed yet another C++-ism in the C headers. While the static_assert you've used is a nice sanity check to make sure structure sizes aren't different from the compiled library, it unfortunately breaks C programs (and really C++ < 11 programs as well). If you must include static_asserts, at the very least put them in a:
#ifdef __cplusplus

or even better an:
#if __cplusplus > 199711L

conditional block.

But really, the most important thing you should do, is have a simple C test program to test with before releasing a new version of the SDK. You can use mine if you like, it's public domain: http://nuclear.mutantstargoat.com/hg/oculus2/file/tip (mercurial repo).

    4 replies

    Inspiring
    January 25, 2015
    Can you give me the filename and line number for one of these asserts?
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Up and Coming
    January 25, 2015
    Just search for "static_assert" in the code I assume.
    Inspiring
    January 25, 2015
    Right, I figured someone would say that. Will check when I'm in the office.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Up and Coming
    January 25, 2015
    I'm hitting a static assert in LibOVR/Src/OVR_CAPI_GL.h line 65:

    ovr_sdk_linux_0.4.4/LibOVR/Src/OVR_CAPI_GL.h:65:14: error: expected constructor, destructor, or type conversion before ‘(’ token
    static_assert(offsetof(ovrGLTextureData, TexId) == offsetof(ovrTexture, PlatformData), "Mismatch of structs that are presumed binary equivalents.");
    ^



    grep static_assert * -rn | wc

    shows 52 other instances in ovr_sdk_linux_0.4.4/.