Skip to content

Commit 998030d

Browse files
committed
Avoid compilation warnings checking for HAVE_* definitions
I originally thought that HAVE_* were defined to 1 or 0 based on whether the function was detected. However, it turns out that HAVE_* is not defined if the function is not detected. Using if instead of ifdef works, but generates a compilation warning when the function is not detected.
1 parent 9b80d37 commit 998030d

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
=== master
2+
3+
* Avoid compilation warnings checking for HAVE_* definitions (jeremyevans)
4+
15
=== 1.18.0 (2025-12-01)
26

37
* Optimize Dataset#all and #with_sql_all (jeremyevans)

ext/sequel_pg/sequel_pg.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#define RARRAY_AREF(a, i) (RARRAY_PTR(a)[i])
2525
#endif
2626

27-
#if !HAVE_RB_HASH_NEW_CAPA
27+
#ifndef HAVE_RB_HASH_NEW_CAPA
2828
#define rb_hash_new_capa(_) rb_hash_new()
2929
#endif
3030

@@ -193,7 +193,7 @@ static ID spg_id_family;
193193
static ID spg_id_addr;
194194
static ID spg_id_mask_addr;
195195

196-
#if HAVE_PQSETSINGLEROWMODE
196+
#ifdef HAVE_PQSETSINGLEROWMODE
197197
static ID spg_id_get_result;
198198
static ID spg_id_clear;
199199
static ID spg_id_check;
@@ -1433,7 +1433,7 @@ static VALUE spg_yield_hash_rows_internal(VALUE self, PGresult *res, int enc_ind
14331433
} else if (rb_type(pg_value) == T_ARRAY) {
14341434
type = SPG_YIELD_COLUMNS_ARRAY;
14351435
}
1436-
#if HAVE_RB_SET_NEW_CAPA
1436+
#ifdef HAVE_RB_SET_NEW_CAPA
14371437
} else if (pg_type == spg_sym_map_set) {
14381438
if (SYMBOL_P(pg_value)) {
14391439
type = SPG_YIELD_COLUMN_SET;
@@ -1449,7 +1449,7 @@ static VALUE spg_yield_hash_rows_internal(VALUE self, PGresult *res, int enc_ind
14491449
type = SPG_YIELD_FIRST_ARRAY;
14501450
} else if (pg_type == spg_sym_array_array) {
14511451
type = SPG_YIELD_ARRAY_ARRAY;
1452-
#if HAVE_RB_SET_NEW_CAPA
1452+
#ifdef HAVE_RB_SET_NEW_CAPA
14531453
} else if (pg_type == spg_sym_first_set) {
14541454
type = SPG_YIELD_FIRST_SET;
14551455
} else if (pg_type == spg_sym_array_set) {
@@ -1542,7 +1542,7 @@ static VALUE spg_yield_hash_rows_internal(VALUE self, PGresult *res, int enc_ind
15421542
rb_yield(ary);
15431543
}
15441544
break;
1545-
#if HAVE_RB_SET_NEW_CAPA
1545+
#ifdef HAVE_RB_SET_NEW_CAPA
15461546
case SPG_YIELD_COLUMN_SET:
15471547
/* Set containing single column */
15481548
{
@@ -1608,7 +1608,7 @@ static VALUE spg_yield_hash_rows_internal(VALUE self, PGresult *res, int enc_ind
16081608
rb_yield(ary);
16091609
}
16101610
break;
1611-
#if HAVE_RB_SET_NEW_CAPA
1611+
#ifdef HAVE_RB_SET_NEW_CAPA
16121612
case SPG_YIELD_FIRST_SET:
16131613
/* Array of first column */
16141614
h = rb_set_new_capa(ntuples);
@@ -1837,14 +1837,14 @@ static VALUE spg_yield_hash_rows(VALUE self, VALUE rres, VALUE ignore) {
18371837

18381838
static VALUE spg_supports_streaming_p(VALUE self) {
18391839
return
1840-
#if HAVE_PQSETSINGLEROWMODE
1840+
#ifdef HAVE_PQSETSINGLEROWMODE
18411841
Qtrue;
18421842
#else
18431843
Qfalse;
18441844
#endif
18451845
}
18461846

1847-
#if HAVE_PQSETSINGLEROWMODE
1847+
#ifdef HAVE_PQSETSINGLEROWMODE
18481848
static VALUE spg_set_single_row_mode(VALUE self) {
18491849
PGconn *conn;
18501850
conn = pg_get_pgconn(self);
@@ -2193,7 +2193,7 @@ void Init_sequel_pg(void) {
21932193

21942194
rb_define_singleton_method(spg_Postgres, "supports_streaming?", spg_supports_streaming_p, 0);
21952195

2196-
#if HAVE_PQSETSINGLEROWMODE
2196+
#ifdef HAVE_PQSETSINGLEROWMODE
21972197
spg_id_get_result = rb_intern("get_result");
21982198
spg_id_clear = rb_intern("clear");
21992199
spg_id_check = rb_intern("check");

0 commit comments

Comments
 (0)