dgorski / app_tdd

TDD Module for Asterisk
3 stars 2 forks source link

Compiler errors with newer versions of spandsp #15

Closed InterLinked1 closed 2 years ago

InterLinked1 commented 2 years ago

I happened to have a system where I upgraded to SpanDSP >= 3.0, and when compiling app_tdd I get several API errors:

Maybe we can detect the installed version of SpanDSP and then proceed accordingly?

app_tdd.c: In function ‘set_logging’:
app_tdd.c:321:38: error: passing argument 2 of ‘span_log_set_message_handler’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  321 |  span_log_set_message_handler(state, spandsp_log);
      |                                      ^~~~~~~~~~~
      |                                      |
      |                                      void (*)(int,  const char *)
In file included from /usr/local/include/spandsp.h:53,
                 from app_tdd.c:33:
/usr/local/include/spandsp/logging.h:123:117: note: expected ‘message_handler_func_t’ {aka ‘void (*)(void *, int,  const char *)’} but argument is of type ‘void (*)(int,  const char * ’
  123 | SPAN_DECLARE(void) span_log_set_message_handler(logging_state_t *s, message_handler_func_t func, void *user_data);
      |                                                                                              ~~~~~~~~~~~~~~~~~~~~~  ^
app_tdd.c:321:2: error: too few arguments to function ‘span_log_set_message_handler’
  321 |  span_log_set_message_handler(state, spandsp_log);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/spandsp.h:53,
                 from app_tdd.c:33:
/usr/local/include/spandsp/logging.h:123:45: note: declared here
  123 | SPAN_DECLARE(void) span_log_set_message_handler(logging_state_t *s, message_handler_func_t func, void *user_data);
      |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
app_tdd.c:322:2: error: implicit declaration of function ‘span_log_set_error_handler’; did you mean ‘span_log_set_message_handler’? [-Werror=implicit-function-declaration]
  322 |  span_log_set_error_handler(state, spandsp_error_log);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |  span_log_set_message_handler
app_tdd.c: In function ‘my_v18_tdd_put_async_byte’:
app_tdd.c:372:15: error: implicit declaration of function ‘v18_decode_baudot’ [-Werror=implicit-function-declaration]
  372 |  if ((octet = v18_decode_baudot(s, byte))) {
      |               ^~~~~~~~~~~~~~~~~
app_tdd.c: In function ‘do_tdd_rx’:
app_tdd.c:722:49: error: passing argument 4 of ‘v18_init’ makes integer from pointer without a cast [-Werror=int-conversion]
  722 |   v18_init(&ti->v18_state, 0, V18_MODE_5BIT_50, tdd_put_msg, ti);
      |                                                 ^~~~~~~~~~~
      |                                                 |
      |                                                 void (*)(void *, const uint8_t *, int) {aka void (*)(void *, const unsigned char *, int)}
In file included from /usr/local/include/spandsp.h:110,
                 from app_tdd.c:33:
/usr/local/include/spandsp/v18.h:125:42: note: expected ‘int’ but argument is of type ‘void (*)(void *, const uint8_t *, int)’ {aka ‘void (*)(void *, const unsigned char *, int)’}
  125 |                                      int nation,
      |                                      ~~~~^~~~~~
app_tdd.c:722:62: error: passing argument 5 of ‘v18_init’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  722 |   v18_init(&ti->v18_state, 0, V18_MODE_5BIT_50, tdd_put_msg, ti);
      |                                                              ^~
      |                                                              |
      |                                                              struct tdd_info *
In file included from /usr/local/include/spandsp.h:110,
                 from app_tdd.c:33:
/usr/local/include/spandsp/v18.h:126:53: note: expected ‘put_msg_func_t’ {aka ‘void (*)(void *, const unsigned char *, int)’} but argument is of type ‘struct tdd_info *’
  126 |                                      put_msg_func_t put_msg,
      |                                      ~~~~~~~~~~~~~~~^~~~~~~
app_tdd.c:722:3: error: too few arguments to function ‘v18_init’
  722 |   v18_init(&ti->v18_state, 0, V18_MODE_5BIT_50, tdd_put_msg, ti);
      |   ^~~~~~~~
In file included from /usr/local/include/spandsp.h:110,
                 from app_tdd.c:33:
/usr/local/include/spandsp/v18.h:122:54: note: declared here
  122 | SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s,
      |                                                      ^
app_tdd.c:724:31: error: ‘V18_MODE_5BIT_45’ undeclared (first use in this function); did you mean ‘V18_MODE_5BIT_476’?
  724 |   v18_init(&ti->v18_state, 0, V18_MODE_5BIT_45, tdd_put_msg, ti);
      |                               ^~~~~~~~~~~~~~~~
      |                               V18_MODE_5BIT_476
app_tdd.c:724:31: note: each undeclared identifier is reported only once for each function it appears in
app_tdd.c:724:49: error: passing argument 4 of ‘v18_init’ makes integer from pointer without a cast [-Werror=int-conversion]
  724 |   v18_init(&ti->v18_state, 0, V18_MODE_5BIT_45, tdd_put_msg, ti);
      |                                                 ^~~~~~~~~~~
      |                                                 |
      |                                                 void (*)(void *, const uint8_t *, int) {aka void (*)(void *, const unsigned char *, int)}
In file included from /usr/local/include/spandsp.h:110,
                 from app_tdd.c:33:
/usr/local/include/spandsp/v18.h:125:42: note: expected ‘int’ but argument is of type ‘void (*)(void *, const uint8_t *, int)’ {aka ‘void (*)(void *, const unsigned char *, int)’}
  125 |                                      int nation,
      |                                      ~~~~^~~~~~
app_tdd.c:724:62: error: passing argument 5 of ‘v18_init’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  724 |   v18_init(&ti->v18_state, 0, V18_MODE_5BIT_45, tdd_put_msg, ti);
      |                                                              ^~
      |                                                              |
      |                                                              struct tdd_info *
In file included from /usr/local/include/spandsp.h:110,
                 from app_tdd.c:33:
/usr/local/include/spandsp/v18.h:126:53: note: expected ‘put_msg_func_t’ {aka ‘void (*)(void *, const unsigned char *, int)’} but argument is of type ‘struct tdd_info *’
  126 |                                      put_msg_func_t put_msg,
      |                                      ~~~~~~~~~~~~~~~^~~~~~~
app_tdd.c:724:3: error: too few arguments to function ‘v18_init’
  724 |   v18_init(&ti->v18_state, 0, V18_MODE_5BIT_45, tdd_put_msg, ti);
      |   ^~~~~~~~
In file included from /usr/local/include/spandsp.h:110,
                 from app_tdd.c:33:
/usr/local/include/spandsp/v18.h:122:54: note: declared here
  122 | SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s,
      |                                                      ^
app_tdd.c:730:12: error: ‘v18_state_t’ {aka ‘struct v18_state_s’} has no member named ‘fskrx’; did you mean ‘fsk_rx’?
  730 |  fs = &vs->fskrx;
      |            ^~~~~
      |            fsk_rx
cc1: all warnings being treated as errors
dgorski commented 2 years ago

So apparently FreeSWITCH released an update to spandsp where they completely broke several key api functions.

I cannot find any information on why they released this, nor why anybody would adopt it. Which seems very sketchy to me.

However, Asterisk seems to have a reasonable patch for this change so I will look into adding something similar here.

https://gerrit.asterisk.org/c/asterisk/+/17332/4/res/res_fax_spandsp.c

dgorski commented 2 years ago

@InterLinked1

I created branch spandsp3-support and applied the neccessary changes. I don't have a spandsp 3.0.0 system to build on, but it still builds cleanly against the older spandsp library.

Can you try to build this branch on your spandsp 3.0.0 system?

If it builds properly for you I'll merge these changes into main.

InterLinked1 commented 2 years ago

Here is trying to compile with your spandsp branch:

Seems to be a lot less broken than before, but still some things that aren't quite right.

Generating input for menuselect ...
menuselect/menuselect --check-deps menuselect.makeopts
menuselect/menuselect --check-deps menuselect.makeopts
   [CPP] app_tdd.c -> app_tdd.i
   [CCi] app_tdd.i -> app_tdd.o
app_tdd.c: In function ‘set_logging’:
app_tdd.c:325:38: error: passing argument 2 of ‘span_log_set_message_handler’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  325 |  span_log_set_message_handler(state, spandsp_log, NULL);
      |                                      ^~~~~~~~~~~
      |                                      |
      |                                      void (*)(int,  const char *)
In file included from /usr/local/include/spandsp.h:53,
                 from app_tdd.c:33:
/usr/local/include/spandsp/logging.h:123:117: note: expected ‘message_handler_func_t’ {aka ‘void (*)(void *, int,  const char *)’} but argument is of type ‘void (*)(int,  const char *)’
  123 | SPAN_DECLARE(void) span_log_set_message_handler(logging_state_t *s, message_handler_func_t func, void *user_data);
      |                                                                                              ~~~~~~~~~~~~~~~~~~~~~  ^
app_tdd.c: In function ‘my_v18_tdd_put_async_byte’:
app_tdd.c:381:15: error: implicit declaration of function ‘decode_baudot’ [-Werror=implicit-function-declaration]
  381 |  if ((octet = decode_baudot(s, byte))) {
      |               ^~~~~~~~~~~~~
app_tdd.c: In function ‘do_tdd_rx’:
app_tdd.c:735:49: error: passing argument 4 of ‘v18_init’ makes integer from pointer without a cast [-Werror=int-conversion]
  735 |   v18_init(&ti->v18_state, 0, V18_MODE_5BIT_50, tdd_put_msg, ti, NULL);
      |                                                 ^~~~~~~~~~~
      |                                                 |
      |                                                 void (*)(void *, const uint8_t *, int) {aka void (*)(void *, const unsigned char *, int)}
In file included from /usr/local/include/spandsp.h:110,
                 from app_tdd.c:33:
/usr/local/include/spandsp/v18.h:125:42: note: expected ‘int’ but argument is of type ‘void (*)(void *, const uint8_t *, int)’ {aka ‘void (*)(void *, const unsigned char *, int)’}
  125 |                                      int nation,
      |                                      ~~~~^~~~~~
app_tdd.c:735:62: error: passing argument 5 of ‘v18_init’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  735 |   v18_init(&ti->v18_state, 0, V18_MODE_5BIT_50, tdd_put_msg, ti, NULL);
      |                                                              ^~
      |                                                              |
      |                                                              struct tdd_info *
In file included from /usr/local/include/spandsp.h:110,
                 from app_tdd.c:33:
/usr/local/include/spandsp/v18.h:126:53: note: expected ‘put_msg_func_t’ {aka ‘void (*)(void *, const unsigned char *, int)’} but argument is of type ‘struct tdd_info *’
  126 |                                      put_msg_func_t put_msg,
      |                                      ~~~~~~~~~~~~~~~^~~~~~~
app_tdd.c:737:31: error: ‘V18_MODE_5BIT_45’ undeclared (first use in this function); did you mean ‘V18_MODE_5BIT_476’?
  737 |   v18_init(&ti->v18_state, 0, V18_MODE_5BIT_45, tdd_put_msg, ti, NULL);
      |                               ^~~~~~~~~~~~~~~~
      |                               V18_MODE_5BIT_476
app_tdd.c:737:31: note: each undeclared identifier is reported only once for each function it appears in
app_tdd.c:737:49: error: passing argument 4 of ‘v18_init’ makes integer from pointer without a cast [-Werror=int-conversion]
  737 |   v18_init(&ti->v18_state, 0, V18_MODE_5BIT_45, tdd_put_msg, ti, NULL);
      |                                                 ^~~~~~~~~~~
      |                                                 |
      |                                                 void (*)(void *, const uint8_t *, int) {aka void (*)(void *, const unsigned char *, int)}
In file included from /usr/local/include/spandsp.h:110,
                 from app_tdd.c:33:
/usr/local/include/spandsp/v18.h:125:42: note: expected ‘int’ but argument is of type ‘void (*)(void *, const uint8_t *, int)’ {aka ‘void (*)(void *, const unsigned char *, int)’}
  125 |                                      int nation,
      |                                      ~~~~^~~~~~
app_tdd.c:737:62: error: passing argument 5 of ‘v18_init’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  737 |   v18_init(&ti->v18_state, 0, V18_MODE_5BIT_45, tdd_put_msg, ti, NULL);
      |                                                              ^~
      |                                                              |
      |                                                              struct tdd_info *
In file included from /usr/local/include/spandsp.h:110,
                 from app_tdd.c:33:
/usr/local/include/spandsp/v18.h:126:53: note: expected ‘put_msg_func_t’ {aka ‘void (*)(void *, const unsigned char *, int)’} but argument is of type ‘struct tdd_info *’
  126 |                                      put_msg_func_t put_msg,
      |                                      ~~~~~~~~~~~~~~~^~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [/usr/src/asterisk-18.14.0/Makefile.rules:150: app_tdd.o] Error 1
make: *** [Makefile:396: apps] Error 2
dgorski commented 2 years ago

@InterLinked1

Thank you, that was very, very helpful. I believe I've addressed each of these as far as I can tell. Let me know how your next build attempt goes.

InterLinked1 commented 2 years ago

Progress! Now it's just this:

app_tdd.c: In function ‘set_logging’:
app_tdd.c:325:36: error: passing argument 2 of ‘span_log_set_message_handler’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  325 |  span_log_set_message_handler(NULL, state, spandsp_log);
      |                                    ^~~~~
      |                                    |
      |                                    logging_state_t * {aka struct logging_state_s *}
In file included from /usr/local/include/spandsp.h:53,
                 from app_tdd.c:33:
/usr/local/include/spandsp/logging.h:123:117: note: expected ‘message_handler_func_t’ {aka ‘void (*)(void *, int,  const char *)’} but argument is of type ‘logging_state_t *’ {aka ‘struct logging_state_s *’}
  123 | SPAN_DECLARE(void) span_log_set_message_handler(logging_state_t *s, message_handler_func_t func, void *user_data);
      |                                                                                              ~~~~~~~~~~~~~~~~~~~~~  ^
app_tdd.c: In function ‘v18_decode_baudot’:
app_tdd.c:348:10: error: ‘BAUDOT_FIGURE_SHIFT’ undeclared (first use in this function)
  348 |     case BAUDOT_FIGURE_SHIFT:
      |          ^~~~~~~~~~~~~~~~~~~
app_tdd.c:348:10: note: each undeclared identifier is reported only once for each function it appears in
app_tdd.c:351:10: error: ‘BAUDOT_LETTER_SHIFT’ undeclared (first use in this function)
  351 |     case BAUDOT_LETTER_SHIFT:
      |          ^~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [/usr/src/asterisk-18.14.0/Makefile.rules:150: app_tdd.o] Error 1
make: *** [Makefile:396: apps] Error 2
root@debian11:/usr/src/asterisk-18.14.0#
dgorski commented 2 years ago

@InterLinked1

OK, I think I got those two issues resolved. Let me know if you can get this one to build.

InterLinked1 commented 2 years ago

Really close:

   [CPP] app_tdd.c -> app_tdd.i
   [CCi] app_tdd.i -> app_tdd.o
app_tdd.c:294:24: error: expected declaration specifiers or ‘...’ before ‘(’ token
  294 | static void spandsp_log(NULL, int level, const char *msg)
      |                        ^
app_tdd.c: In function ‘set_logging’:
app_tdd.c:329:38: error: ‘spandsp_log’ undeclared (first use in this function); did you mean ‘span_log’?
  329 |  span_log_set_message_handler(state, spandsp_log, NULL);
      |                                      ^~~~~~~~~~~
      |                                      span_log
app_tdd.c:329:38: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [/usr/src/asterisk-18.14.0/Makefile.rules:150: app_tdd.o] Error 1
make: *** [Makefile:396: apps] Error 2
dgorski commented 2 years ago

@InterLinked1

Sorry, I noticed that after I posted - I didn't try to build it locally first. I fixed it and it's compiling on my spandsp 0.0.6 machine now.

Sorry about that. Should be all set.

InterLinked1 commented 2 years ago

Yes, it compiles now - thank you!

dgorski commented 2 years ago

@InterLinked1

Thanks for that. Were you able to do any basic testing with it? Just curious about the new spandsp really.

dgorski commented 2 years ago

@InterLinked1

Merged back to main - if you have any problems using spandsp 3.0.0 open another issue and I'll look into it.