Skip to content

Commit

Permalink
Use -std=c99 when building with CMake
Browse files Browse the repository at this point in the history
Disable the GNU extensions in CMake which is ON by default
for some reason. This is the same as in Makefile builds.
Enable GNU extensions where required.

Signed-off-by: Björn Svensson <[email protected]>
  • Loading branch information
bjosv committed Oct 6, 2024
1 parent 1d9e49c commit 2267965
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ OPTION(ENABLE_EXAMPLES "Enable building valkey examples" OFF)
option(ENABLE_IPV6_TESTS "Enable IPv6 tests requiring special prerequisites" OFF)
OPTION(ENABLE_RDMA "Build valkey_rdma for RDMA support" OFF)

# valkey requires C99
# Libvalkey requires C99 (-std=c99)
SET(CMAKE_C_STANDARD 99)
set(CMAKE_C_EXTENSIONS OFF)
SET(CMAKE_DEBUG_POSTFIX d)

# Set target-common flags
Expand Down
1 change: 1 addition & 0 deletions examples/async-libsdevent.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define _XOPEN_SOURCE 600 /* Required by libsdevent (CLOCK_MONOTONIC) */
#include <valkey/async.h>
#include <valkey/valkey.h>

Expand Down
1 change: 1 addition & 0 deletions examples/async-libuv.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define _XOPEN_SOURCE 600 /* Required by libuv (pthread_rwlock_t) */
#include <valkey/async.h>
#include <valkey/valkey.h>

Expand Down
1 change: 1 addition & 0 deletions examples/blocking.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define _XOPEN_SOURCE 600 /* For strdup() */
#include <valkey/valkey.h>

#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#define _XOPEN_SOURCE 600
#include "fmacros.h"
#include "win32.h"

#include "cluster.h"
Expand Down
5 changes: 2 additions & 3 deletions tests/client_test.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#if !defined(__FreeBSD__)
#define _POSIX_C_SOURCE 200112L
#endif
#include "fmacros.h"

#include "sockcompat.h"

#include <stdio.h>
Expand Down
1 change: 1 addition & 0 deletions tests/ct_async_libuv.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define _XOPEN_SOURCE 600 /* Required by libuv (pthread_rwlock_t) */
#include "adapters/libuv.h"
#include "cluster.h"
#include "test_utils.h"
Expand Down
1 change: 1 addition & 0 deletions tests/ct_commands.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define _XOPEN_SOURCE 600 /* For strdup() */
#include "cluster.h"
#include "test_utils.h"

Expand Down
1 change: 1 addition & 0 deletions tests/ut_parse_cmd.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Some unit tests that don't require Valkey to be running. */

#include "fmacros.h"
#include "win32.h"

#include "cluster.h"
Expand Down

0 comments on commit 2267965

Please sign in to comment.