diff --git a/bindings/c/CMakeLists.txt b/bindings/c/CMakeLists.txt index f4e5a762ac..cf3a4f1a3a 100644 --- a/bindings/c/CMakeLists.txt +++ b/bindings/c/CMakeLists.txt @@ -111,6 +111,12 @@ if(NOT WIN32) set_property(TARGET mako PROPERTY SKIP_BUILD_RPATH TRUE) target_link_libraries(mako PRIVATE fdb_c) + # Make sure that fdb_c.h is compatible with c90 + add_executable(fdb_c90_test test/fdb_c90_test.c) + set_property(TARGET fdb_c90_test PROPERTY C_STANDARD 90) + target_compile_options(fdb_c90_test PRIVATE -Wall -Wextra -Wpedantic -Werror) + target_link_libraries(fdb_c90_test PRIVATE fdb_c) + add_fdbclient_test( NAME fdb_c_setup_tests COMMAND $) diff --git a/bindings/c/foundationdb/fdb_c.h b/bindings/c/foundationdb/fdb_c.h index 1723a4c6ec..5fa7e4d459 100644 --- a/bindings/c/foundationdb/fdb_c.h +++ b/bindings/c/foundationdb/fdb_c.h @@ -45,12 +45,17 @@ #define WARN_UNUSED_RESULT #endif -// With default settings, gcc will not warn about unprototyped functions being called, so it -// is easy to erroneously call a function which is not available at FDB_API_VERSION and then -// get an error only at runtime. These macros ensure a compile error in such cases, and -// attempt to make the compile error slightly informative. -#define This_FoundationDB_API_function_is_removed_at_this_FDB_API_VERSION() [=====] -#define FDB_REMOVED_FUNCTION This_FoundationDB_API_function_is_removed_at_this_FDB_API_VERSION(0) +/* + * With default settings, gcc will not warn about unprototyped functions being + * called, so it is easy to erroneously call a function which is not available + * at FDB_API_VERSION and then get an error only at runtime. These macros + * ensure a compile error in such cases, and attempt to make the compile error + * slightly informative. + */ +#define This_FoundationDB_API_function_is_removed_at_this_FDB_API_VERSION() \ + [== == = ] +#define FDB_REMOVED_FUNCTION \ + This_FoundationDB_API_function_is_removed_at_this_FDB_API_VERSION(0) #include @@ -248,12 +253,15 @@ extern "C" { fdb_transaction_get_committed_version( FDBTransaction* tr, int64_t* out_version ); - // This function intentionally returns an FDBFuture instead of an integer directly, - // so that calling this API can see the effect of previous mutations on the transaction. - // Specifically, mutations are applied asynchronously by the main thread. In order to - // see them, this call has to be serviced by the main thread too. - DLLEXPORT WARN_UNUSED_RESULT FDBFuture* - fdb_transaction_get_approximate_size(FDBTransaction* tr); + /* + * This function intentionally returns an FDBFuture instead of an integer + * directly, so that calling this API can see the effect of previous + * mutations on the transaction. Specifically, mutations are applied + * asynchronously by the main thread. In order to see them, this call has to + * be serviced by the main thread too. + */ + DLLEXPORT WARN_UNUSED_RESULT FDBFuture * + fdb_transaction_get_approximate_size(FDBTransaction *tr); DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_get_server_protocol(const char* clusterFilePath); @@ -305,7 +313,7 @@ extern "C" { typedef struct FDB_cluster FDBCluster; typedef enum { - // This option is only a placeholder for C compatibility and should not be used + /* This option is only a placeholder for C compatibility and should not be used */ FDB_CLUSTER_OPTION_DUMMY_DO_NOT_USE=-1 } FDBClusterOption; #endif diff --git a/bindings/c/test/fdb_c90_test.c b/bindings/c/test/fdb_c90_test.c new file mode 100644 index 0000000000..1569d98250 --- /dev/null +++ b/bindings/c/test/fdb_c90_test.c @@ -0,0 +1,9 @@ +#define FDB_API_VERSION 700 +#include + +int main(int argc, char* argv[]) { + (void)argc; + (void)argv; + fdb_select_api_version(700); + return 0; +} diff --git a/fdbclient/vexillographer/c.cs b/fdbclient/vexillographer/c.cs index ee718495a5..2ea6675dff 100644 --- a/fdbclient/vexillographer/c.cs +++ b/fdbclient/vexillographer/c.cs @@ -52,8 +52,8 @@ namespace vexillographer { string parameterComment = ""; if (o.scope.ToString().EndsWith("Option")) - parameterComment = String.Format("{0}// {1}\n", indent, "Parameter: " + o.getParameterComment()); - return String.Format("{0}// {2}\n{5}{0}{1}{3}={4}", indent, prefix, o.comment, o.name.ToUpper(), o.code, parameterComment); + parameterComment = String.Format("{0}/* {1} */\n", indent, "Parameter: " + o.getParameterComment()); + return String.Format("{0}/* {2} */\n{5}{0}{1}{3}={4}", indent, prefix, o.comment, o.name.ToUpper(), o.code, parameterComment); } private static void writeCEnum(TextWriter outFile, Scope scope, IEnumerable