Skip to content

compile problem: comparison between pointer and zero character constant [-Wpointer-compare] #47

@taoqxtaozi

Description

@taoqxtaozi

Hi,

When I compile the C files, I get such warnings:

/root/miniconda3/bin/x86_64-conda-linux-gnu-cc -std=c99 -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /root/miniconda3/include -O3 -g -Wall --pedantic -funroll-loops -DNDEBUG       -I../externalTools/quicktree_1.1/include/ -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /root/miniconda3/include -I inc -I ../lib/  -c impl/*.c
impl/bioioC.c: In function 'parseInt':
impl/bioioC.c:268:23: warning: comparison between pointer and zero character constant [-Wpointer-compare]
  268 |         while(*string != '\0' && !isspace(**string)) {
      |                       ^~
impl/bioioC.c:268:15: note: did you mean to dereference the pointer?
  268 |         while(*string != '\0' && !isspace(**string)) {
      |               ^
impl/bioioC.c: In function 'parseFloat':
impl/bioioC.c:289:23: warning: comparison between pointer and zero character constant [-Wpointer-compare]
  289 |         while(*string != '\0' && !isspace(**string)) {
      |                       ^~
impl/bioioC.c:289:15: note: did you mean to dereference the pointer?
  289 |         while(*string != '\0' && !isspace(**string)) {
      |               ^
impl/bioioC.c: In function 'parseString':
impl/bioioC.c:310:23: warning: comparison between pointer and zero character constant [-Wpointer-compare]
  310 |         while(*string != '\0' && !isspace(**string)) {
      |                       ^~
impl/bioioC.c:310:15: note: did you mean to dereference the pointer?
  310 |         while(*string != '\0' && !isspace(**string)) {
      |               ^
impl/sonLibList.c: In function 'st_list_sortP':
impl/sonLibList.c:258:13: warning: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic]
  258 |     return ((int (*)(const void *, const void *))fn)(*((char **)a), *((char **)b));
      |             ^
impl/sonLibList.c: In function 'stList_sort':
impl/sonLibList.c:262:76: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
  262 |     sort_r(list->list, stList_length(list), sizeof(void *), st_list_sortP, (void *)cmpFn);
      |                                                                            ^
impl/sonLibList.c: In function 'st_list_sort2P':
impl/sonLibList.c:267:56: warning: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic]
  267 |     int (*cmpFn)(const void *, const void *, void *) = (int (*)(const void *, const void *, void *))(((void **)extra)[0]);
      |                                                        ^
impl/sonLibList.c: In function 'stList_sort2':
impl/sonLibList.c:273:24: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
  273 |     void *extra[2] = { (void *)cmpFn, (void *)extraArg };

and finally when I try commands in ./bin, I get Segmentation fault. I think it's the pointer problem, but I see many platforms and get no solutions.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions