diff --git a/src/Makefile.am b/src/Makefile.am index 3f308e355..a4a31bb01 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -190,7 +190,7 @@ clang-tidy: ../compile_commands.json # emacs flymake-mode check-syntax: test -n "$(CHK_SOURCES)" && \ - nice $(COMPILE) -O0 -o /dev/null -S $(CHK_SOURCES) + nice $(COMPILE) -I. -O0 -o /dev/null -S $(CHK_SOURCES) .PHONY: check-syntax cppcheck clang-tidy if ENABLE_GCOV diff --git a/src/bits.c b/src/bits.c index 62049567c..e76fece17 100644 --- a/src/bits.c +++ b/src/bits.c @@ -2070,7 +2070,7 @@ bit_wcs2dup (const BITCODE_TU restrict src) return NULL; len = bit_wcs2len (src); blen = (len + 1) * 2; // include the zero - d = malloc (blen); + d = (BITCODE_TU)malloc (blen); if (d) memcpy (d, src, blen); return d; @@ -2173,12 +2173,12 @@ bit_write_TV (Bit_Chain *restrict dat, BITCODE_TV restrict chain) if (length && dat->opts & DWG_OPTS_INJSON) { size_t destlen = length * 2; - char *dest = malloc (destlen); + char *dest = (char*)malloc (destlen); while (!bit_utf8_to_TV (dest, (unsigned char *)chain, destlen, length, 0, dat->codepage)) { destlen *= 2; - dest = realloc (dest, destlen); + dest = (char*)realloc (dest, destlen); } need_free = true; chain = dest; diff --git a/src/codepages.c b/src/codepages.c index f902d1a07..df261992e 100644 --- a/src/codepages.c +++ b/src/codepages.c @@ -451,7 +451,7 @@ dwg_codepage_isalnum (const Dwg_Codepage cp, const wchar_t c) const uint8_t key = c & 0xff; const uint8_t sz8 = fntbl[0]; const size_t sz = (size_t)sz8; - uint8_t *found = bsearch (&key, &fntbl[1], sz, 1, b8_cmp); + uint8_t *found = (uint8_t *)bsearch (&key, &fntbl[1], sz, 1, b8_cmp); if (!found || found == &fntbl[0]) return false; else @@ -463,7 +463,7 @@ dwg_codepage_isalnum (const Dwg_Codepage cp, const wchar_t c) const uint16_t *fntbl16 = cp_alnum16tbl[cp]; const uint16_t sz16 = fntbl16[0]; const size_t sz = (size_t)sz16; - uint16_t *found = bsearch (&key, &fntbl16[1], sz, 2, b16_cmp); + uint16_t *found = (uint16_t *)bsearch (&key, &fntbl16[1], sz, 2, b16_cmp); if (!found || found == &fntbl16[0]) return false; else diff --git a/src/decode.c b/src/decode.c index 740b9508b..bbce86eac 100644 --- a/src/decode.c +++ b/src/decode.c @@ -2590,7 +2590,13 @@ secondheader_private (Bit_Chain *restrict dat, Dwg_Data *restrict dwg) Bit_Chain *str_dat = dat; Dwg_SecondHeader *_obj = &dwg->secondheader; // for error logging only: +#ifndef __cplusplus Dwg_Object *obj = &(Dwg_Object){ .name = (char *)"2NDHEADER" }; +#else + Dwg_Object xobj; + xobj.name = (char *)"2NDHEADER"; + Dwg_Object *obj = &xobj; +#endif int error = 0; BITCODE_BL vcount; if (!dat->chain || !dat->size) diff --git a/src/dwg_api.c b/src/dwg_api.c index 609a596d3..70aeedbba 100644 --- a/src/dwg_api.c +++ b/src/dwg_api.c @@ -22000,7 +22000,7 @@ EXPORT bool dwg_is_valid_name_u8 (Dwg_Data *restrict dwg, const char *restrict name) { Dwg_Version_Type version = dwg->header.version; - const Dwg_Codepage cp = dwg->header.codepage; + const Dwg_Codepage cp = (const Dwg_Codepage)dwg->header.codepage; BITCODE_TU wstr; size_t wlen; #ifndef HAVE_NONNULL @@ -22067,7 +22067,7 @@ EXPORT bool dwg_is_valid_name (Dwg_Data *restrict dwg, const char *restrict name) { Dwg_Version_Type version = dwg->header.version; - const Dwg_Codepage cp = dwg->header.codepage; + const Dwg_Codepage cp = (const Dwg_Codepage)dwg->header.codepage; #ifndef HAVE_NONNULL if (!name) return false; diff --git a/src/encode.c b/src/encode.c index a1ed37772..6d1bc7540 100644 --- a/src/encode.c +++ b/src/encode.c @@ -89,7 +89,11 @@ static BITCODE_BL rcount1 = 0, rcount2 = 0; SECTION_R13_SIZE is the size and the sentinel. */ #define SECTION_R13_SIZE 7U -static Dwg_Section_Type_r13 section_order[SECTION_R13_SIZE] = { 0 }; +static Dwg_Section_Type_r13 section_order[SECTION_R13_SIZE] +#ifndef __cplusplus + = { 0 } +#endif + ; #ifdef USE_TRACING /* This flag means we have checked the environment variable @@ -2083,7 +2087,7 @@ section_remove (Dwg_Section_Type_r13 *psection_order, BITCODE_RL *pnum, (*pnum)--; memmove (&psection_order[i], &psection_order[i + 1], (*pnum - i) * sizeof (Dwg_Section_Type_r13)); - psection_order[*pnum] = SECTION_R13_SIZE; // sentinel (invalid) + psection_order[*pnum] = (Dwg_Section_Type_r13)SECTION_R13_SIZE; // sentinel (invalid) return 1; } @@ -2247,7 +2251,7 @@ encode_check_num_sections (Dwg_Section_Type_r11 id, Dwg_Data *restrict dwg) num_sections = dwg->header.num_sections + 2; if (!id) { - id = num_sections; + id = (Dwg_Section_Type_r11)num_sections; dwg->header.sections = dwg->header.num_sections; } if ((BITCODE_RL)id >= num_sections) @@ -2481,7 +2485,13 @@ encode_secondheader_private (Bit_Chain *restrict dat, Dwg_Data *restrict dwg) Bit_Chain *str_dat = dat; Dwg_SecondHeader *_obj = &dwg->secondheader; // for error logging only: +#ifndef __cplusplus Dwg_Object *obj = &(Dwg_Object){ .name = (char *)"2NDHEADER" }; +#else + Dwg_Object xobj; + xobj.name = (char *)"2NDHEADER"; + Dwg_Object *obj = &xobj; +#endif int error = 0; BITCODE_BL vcount; if (!dat->chain || !dat->size) @@ -3539,7 +3549,7 @@ dwg_encode (Dwg_Data *restrict dwg, Bit_Chain *restrict dat) // patch all the section tbl->address addr = dwg->header.entities_end + (dat->version >= R_11 ? 0x20 : 0); - encode_check_num_sections (dwg->header.num_sections, dwg); + encode_check_num_sections ((Dwg_Section_Type_r11)dwg->header.num_sections, dwg); if (dwg->header.from_version >= R_13b1) { /* r2000 has e.g. @@ -3893,8 +3903,7 @@ dwg_encode (Dwg_Data *restrict dwg, Bit_Chain *restrict dat) } VERSIONS (R_13b1, R_2000) { - for (Dwg_Section_Type_r13 id = 0; - (unsigned)id < (unsigned)dwg->header.num_sections; id++) + for (unsigned id = 0; id < dwg->header.num_sections; id++) { switch (section_order[id]) { @@ -6690,13 +6699,13 @@ dwg_encode_xdata (Bit_Chain *restrict dat, Dwg_Object_XRECORD *restrict _obj, if (rbuf->value.str.size > 0 && dat->opts & DWG_OPTS_INJSON) { BITCODE_RS destlen = rbuf->value.str.size * 2; - char *dest = malloc (destlen); + char *dest = (char *)malloc (destlen); while (!bit_utf8_to_TV ( dest, (BITCODE_TF)rbuf->value.str.u.data, destlen, rbuf->value.str.size, 0, rbuf->value.str.codepage)) { destlen *= 2; - dest = realloc (dest, destlen); + dest = (char *)realloc (dest, destlen); } destlen = (BITCODE_RS)strlen (dest); bit_write_RS (dat, destlen); @@ -7756,7 +7765,7 @@ dwg_convert_LTYPE_strings_area (const Dwg_Data *restrict dwg, _obj->has_strings_area = 0; return; } - _obj->strings_area = calloc (1, 512); + _obj->strings_area = (BITCODE_TF)calloc (1, 512); if (!_obj->strings_area) { _obj->has_strings_area = 0; @@ -7776,7 +7785,7 @@ dwg_convert_LTYPE_strings_area (const Dwg_Data *restrict dwg, BITCODE_TF old = _obj->strings_area; if (!old) _obj->has_strings_area = 0; - _obj->strings_area = calloc (1, 256); + _obj->strings_area = (BITCODE_TF)calloc (1, 256); if (!_obj->strings_area || !old) { // all empty if (old)