1

I'm trying to compile OpenHMD in Visual Studio 2010. I started with a Win32 library project layout. I noticed that stdafx.cpp was created and removed that file along with generated headers. Now I still get compilation errors like these (inlined as comments):

OHMD_APIENTRY int ohmd_ctx_probe(ohmd_context* ctx)
{
    memset(&ctx->list, 0, sizeof(ohmd_device_list));
    int i;  // <-- error C2143: syntax error : missing ';' before 'type'
    for(i = 0; i < ctx->num_drivers; i++){  // <-- error C2065: 'i' : undeclared identifier
        ctx->drivers[i]->get_device_list(ctx->drivers[i], &ctx->list);
    }

    return ctx->list.num_devices;
}

Where can I force plain C compilation or set the C-Language level C99? This appears to be a C89 issue?

Note: I already changed the for loop from

for(int i = 0;  ...

to

int i;
for( i = 0; ...
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
stacker
  • 68,052
  • 28
  • 140
  • 210
  • Possible duplicate of [Visual Studio 2010 Compiling C code](http://stackoverflow.com/questions/2985548/visual-studio-2010-compiling-c-code) — or perhaps [Does Microsoft Visual Studio 2010 support C99?](http://stackoverflow.com/questions/6688895/does-microsoft-visual-studio-2010-support-c99), which sounds like a better match but ends up focussing on the types in ``. – Jonathan Leffler Aug 24 '13 at 18:54

1 Answers1

5

Visual Studio doesn't support C99, and Microsoft has no plans to support it, see here: http://www.drdobbs.com/cpp/interview-with-herb-sutter/231900562

Crowman
  • 25,242
  • 5
  • 48
  • 56
  • Thanks, this is simply unbelievable, either I have to change all the code manually or read hours on cross-compiling. – stacker Aug 24 '13 at 18:34
  • C99 introduced some great stuff. Would MinGW fulfill your needs? – John Aug 24 '13 at 18:43
  • 3
    Yes - I understand that their development front is focused on C++, and C#, and the like, but still, I also find it a little unbelievable that the largest software company in the world doesn't have, and apparently isn't interested in ever having, a C compiler that supports a 14 year old standard. – Crowman Aug 24 '13 at 18:45
  • 1
    Sad, but it seems to be so. There is discussion, I believe, about maybe supporting C11, but there will be compatibility problems between their library functions and the standard C library functions of the same name — and some of the problems can't be resolved by the use of suitable typedefs, even though the standard tries to make it possible. See [Do you use the TR24731 'safe' functions?](http://stackoverflow.com/questions/372980/do-you-use-the-tr-24731-safe-functions) for some more information and examples. – Jonathan Leffler Aug 24 '13 at 18:56