jordansissel / xdotool

fake keyboard/mouse input, window management, and more
Other
3.26k stars 320 forks source link

incompatible integer to pointer conversion error #466

Open chenrui333 opened 3 months ago

chenrui333 commented 3 months ago

👋 while regression build 3.20211022.1 release, I found some incompatible integer to pointer conversion error as below

  clang -Wno-implicit-function-declaration -g    -std=c99 -I/opt/homebrew/Cellar/libxau/1.0.11/include -I/opt/homebrew/Cellar/libxdmcp/1.1.5/include -I/opt/homebrew/Cellar/libxcb/1.17.0/include -I/opt/homebrew/Cellar/libx11/1.8.10/include -I/opt/homebrew/Cellar/libxext/1.3.6/include -I/opt/homebrew/Cellar/libxinerama/1.1.5/include -I/opt/homebrew/Cellar/libxfixes/6.0.1/include -I/opt/homebrew/Cellar/libxkbcommon/1.7.0/include -I/opt/homebrew/Cellar/libxi/1.8.1/include -I/opt/homebrew/Cellar/libxtst/1.2.5/include -I/opt/homebrew/Cellar/xorgproto/2024.1/include   -c -o cmd_click.o cmd_click.c
  xdo.c:1394:24: error: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
    keyseq_copy = strptr = strdup(keyseq);
                         ^ ~~~~~~~~~~~~~~
  1 error generated.

relates to https://github.com/Homebrew/homebrew-core/pull/180081

jordansissel commented 3 months ago

I’m on my phone so I can’t test right now, so I can just go with looking at the code and the error message.

based on the code:

https://github.com/jordansissel/xdotool/blob/eb489de1b4fb3fd0cd935d68ae16ecd4c653ac7d/xdo.c#L1394

all items appear to be char here (including the return type of strdup), and none should be int. I’m not sure I understand why it’s reporting an int-char conversion in this scenario.

jordansissel commented 3 months ago

Oh I wonder if on macOS we are missing a header declaration for strdup? C function default type is int if undeclared.

jordansissel commented 3 months ago

macOS docs indicate strdup comes from string.h which xdo.c does include. I’m unable to dig into this further without being on my computer. If yall find anything, let me know :)

also, does this still fail on the master branch?