gkdr/axc

[0.3.3] src/axc.c compile warnings that could be of interest

hartwork opened this issue · 6 comments

src/axc.c:34:16: warning: struct has no members [-Wpedantic]
   34 | typedef struct axc_mutexes {
      |                ^~~~~~~~~~~
src/axc.c: In function ‘axc_pre_key_message_process’:
src/axc.c:1074:12: warning: unused variable ‘pre_key_id’ [-Wunused-variable]
 1074 |   uint32_t pre_key_id = 0;
      |            ^~~~~~~~~~
gkdr commented

thanks for the issue!

  • iirc, the first one is due to how i disable threading support. i implemented it using pthread (which causes problems when compiling for windows) and libpurple (probably the only thing this is used for?) is single threaded anyway. so i just remove the code using macros, resulting (among ohter things) in this warning. do you have a hint for me for a better solution to this problem?
  • the second one was noticed in #17 and if i understood it correctly, @henry-nicolas will file a PR for this. not sure why i missed that when removing the usage of the internal API that was used for.

For former: Do you think that the whole axc_mutexes struct could be hid away by the pre-processor or is there some reason why it has to exist when e.g. compiling for Windows?

Linked to:

gkdr commented

@hartwork i assumed that i only hid these parts for a reason, but now that you ask i'm not sure the reason wasn't just that it's the quickest solution. i glanced over it and it seems that by hiding some more code via the preprocessor, i could in fact completely hide this feature from the compiler.

however, it still bugs me: is that really how feature flags are implemented?

@hartwork i assumed that i only hid these parts for a reason, but now that you ask i'm not sure the reason wasn't just that it's the quickest solution. i glanced over it and it seems that by hiding some more code via the preprocessor, i could in fact completely hide this feature from the compiler.

Cool!

however, it still bugs me: is that really how feature flags are implemented?

I'm not sure. Adding a dummy field to avoid an empty struct might be an alternative hack, but if the whole struct can disappear, maybe it's not even bad.

@gkdr I thought about it again: keeping -Wpedantic and having it clean has some value in my book, so I made pull request #29 now to get to that state.