Newbie question.
I am trying to get libcork to compile with VS2010.
In C I guess you typically have to declare variables at the beginning of the function like this:
void
cork_hash_table_clear(struct cork_hash_table *table)
{
DEBUG("(clear) Removing all entries");
size_t i; // <--- fails to compile unless moved before DEBUG.
...
But libcork is rife with definitions/declarations as they are used in code. I wonder if there is a VS compiler option that allows this? I’m sorry if this question is not new, but all I get is a syntax error and I don’t have any helpful terms to use to search the VS docs.
Intermixed declarations and statements within a function were introduced into C in the 1999 version of the standard (C99); unfortunately VS decided not to follow the standard past the 1990 version.
You may be able to compile the code as C++, although this could well break in interesting ways as C is not a strict subset of C++. Herb Sutter recommends using Intel CC or gcc if the code is not compatible with C++.
The question Visual Studio support for new C / C++ standards? has some interesting content, although it covers C++ as well (where VS is far better at keeping pace).