Skip to content

Commit 10263fd

Browse files
author
Reini Urban
committed
[GH #70] Enable clang++ compilation, proper function ptr casts
Also fix a wrong C++ precedence: & has lower precedence than ==; == will be evaluated first [-Wparentheses]
1 parent 8ea7814 commit 10263fd

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

3rdparty/libtommath/bn_error.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ static const struct {
2525
};
2626

2727
/* return a char * string for a given code */
28-
char *mp_error_to_string(int code)
28+
const char *mp_error_to_string(int code)
2929
{
3030
int x;
3131

3232
/* scan the lookup table for the given message */
3333
for (x = 0; x < (int)(sizeof(msgs) / sizeof(msgs[0])); x++) {
3434
if (msgs[x].code == code) {
35-
return msgs[x].msg;
35+
return msgs[x].msg;
3636
}
3737
}
3838

3rdparty/libtommath/tommath.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat);
190190
#define SIGN(m) ((m)->sign)
191191

192192
/* error code to char* string */
193-
char *mp_error_to_string(int code);
193+
const char *mp_error_to_string(int code);
194194

195195
/* ---> init and deinit bignum functions <--- */
196196
/* init a bignum */

src/6model/repr_registry.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static void register_repr(PARROT_INTERP, STRING *name, REPROps *repr) {
174174
/* Dynamically registers a representation (that is, one defined outside of
175175
* the 6model core). */
176176
static INTVAL REPR_register_dynamic(PARROT_INTERP, STRING *name, REPROps * (*reg) (PARROT_INTERP, void *, void *)) {
177-
REPROps *repr = reg(interp, wrap_object, create_stable);
177+
REPROps *repr = reg(interp, (void*)wrap_object, (void*)create_stable);
178178
register_repr(interp, name, repr);
179179
return repr->ID;
180180
}
@@ -206,7 +206,7 @@ void REPR_initialize_registry(PARROT_INTERP) {
206206

207207
/* Set up object for dynamically registering extra representations. */
208208
dyn_reg_func = Parrot_pmc_new(interp, enum_class_Pointer);
209-
VTABLE_set_pointer(interp, dyn_reg_func, REPR_register_dynamic);
209+
VTABLE_set_pointer(interp, dyn_reg_func, (void*)REPR_register_dynamic);
210210
VTABLE_set_pmc_keyed_str(interp, interp->root_namespace,
211211
Parrot_str_new_constant(interp, "_REGISTER_REPR"), dyn_reg_func);
212212
}

src/guts/multi_dispatch.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ static NQP_md_cache *get_dispatch_cache(PARROT_INTERP, PMC *dispatcher) {
282282
if (dispatcher->vtable->base_type == enum_class_Sub && PARROT_SUB(dispatcher)->multi_signature->vtable->base_type == smo_id) {
283283
NQP_Routine *r = (NQP_Routine *)PMC_data(PARROT_SUB(dispatcher)->multi_signature);
284284
if (PMC_IS_NULL(r->dispatch_cache)) {
285-
NQP_md_cache *c = mem_sys_allocate_zeroed(sizeof(NQP_md_cache));
285+
NQP_md_cache *c = (NQP_md_cache *)mem_sys_allocate_zeroed(sizeof(NQP_md_cache));
286286
cache_ptr = Parrot_pmc_new(interp, enum_class_Pointer);
287287
VTABLE_set_pointer(interp, cache_ptr, c);
288288
r->dispatch_cache = cache_ptr;
@@ -401,8 +401,8 @@ add_to_cache(PARROT_INTERP, NQP_md_cache *cache, PMC *capture, INTVAL num_args,
401401

402402
/* If there's no entries yet, need to do some allocation. */
403403
if (entries == 0) {
404-
cache->arity_caches[num_args - 1].type_ids = mem_sys_allocate(num_args * sizeof(INTVAL) * MD_CACHE_MAX_ENTRIES);
405-
cache->arity_caches[num_args - 1].results = mem_sys_allocate(sizeof(PMC *) * MD_CACHE_MAX_ENTRIES);
404+
cache->arity_caches[num_args - 1].type_ids = (INTVAL *)mem_sys_allocate(num_args * sizeof(INTVAL) * MD_CACHE_MAX_ENTRIES);
405+
cache->arity_caches[num_args - 1].results = (PMC **)mem_sys_allocate(sizeof(PMC *) * MD_CACHE_MAX_ENTRIES);
406406
}
407407

408408
/* Add entry. */

src/ops/nqp.ops

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,11 @@ inline op nqp_dynop_setup() :base_core {
326326
/* Set up write barrier functions. */
327327
/* XXX Really want a better, cheaper place to put them... */
328328
obj_sc_barrier = Parrot_pmc_new(interp, enum_class_Pointer);
329-
VTABLE_set_pointer(interp, obj_sc_barrier, SC_write_barrier_obj);
329+
VTABLE_set_pointer(interp, obj_sc_barrier, (void*)SC_write_barrier_obj);
330330
VTABLE_set_pmc_keyed_str(interp, interp->root_namespace,
331331
Parrot_str_new_constant(interp, "_OBJ_SC_BARRIER"), obj_sc_barrier);
332332
st_sc_barrier = Parrot_pmc_new(interp, enum_class_Pointer);
333-
VTABLE_set_pointer(interp, st_sc_barrier, SC_write_barrier_st);
333+
VTABLE_set_pointer(interp, st_sc_barrier, (void*)SC_write_barrier_st);
334334
VTABLE_set_pmc_keyed_str(interp, interp->root_namespace,
335335
Parrot_str_new_constant(interp, "_ST_SC_BARRIER"), st_sc_barrier);
336336

src/ops/nqp_dyncall.ops

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,9 @@ unmarshal_string(PARROT_INTERP, PMC *value, INTVAL type, INTVAL *free) {
409409
else {
410410
str = Parrot_str_to_encoded_cstring(interp,
411411
REPR(value)->box_funcs->get_str(interp, STABLE(value), OBJECT_BODY(value)),
412-
type & DYNCALL_ARG_TYPE_MASK == DYNCALL_ARG_ASCIISTR ? Parrot_ascii_encoding_ptr :
413-
type & DYNCALL_ARG_TYPE_MASK == DYNCALL_ARG_UTF16STR ? Parrot_utf16_encoding_ptr :
414-
Parrot_utf8_encoding_ptr);
412+
(type & DYNCALL_ARG_TYPE_MASK) == DYNCALL_ARG_ASCIISTR ? Parrot_ascii_encoding_ptr :
413+
(type & DYNCALL_ARG_TYPE_MASK) == DYNCALL_ARG_UTF16STR ? Parrot_utf16_encoding_ptr :
414+
Parrot_utf8_encoding_ptr);
415415

416416
if (free && type & DYNCALL_ARG_FREE_STR_MASK) {
417417
*free = 1;
@@ -531,7 +531,7 @@ unmarshal_callback(PARROT_INTERP, PMC *value, PMC *info) {
531531
data->interp = interp;
532532
data->sub = value;
533533

534-
data->cb = dcbNewCallback(signature, &callback_handler, data);
534+
data->cb = dcbNewCallback((const char *)signature, (DCCallbackHandler*)&callback_handler, data);
535535

536536
mem_sys_free(signature); /* XXX: Not entirely sure if I can do this... */
537537

0 commit comments

Comments
 (0)