Deprecated conversion from string to 'char*'

    Feb 19 2010 | 11:58 pm
    after upgrading to Snow Leopard and the latest Xcode (with a possibly new version of GCC) I started getting tons of this warning:
    Deprecated conversion from string to 'char*'
    After examining the problem I realized that SDK functions like gensym, object_post etc. are declared with char * arguments instead of const char *. Although this is not a de facto error, C/C++ function declaration guidelines usually recommend declaring every argument that won't be changed by the function as const (I suppose they introduced this particular warning to remind developers about this fact). There are many reasons why this guideline exists, and although I'm sure I could disable this particular warning with some compiler flag, I decided to overwrite the definitions in the respective SDK headers (mainly ext_proto.h) as this makes a cleaner situation.
    Would it be possible for the developers of the SDK to fix this small inconvenience in a future release of the SDK?
    Thanks, Adam

    • Feb 22 2010 | 11:46 am
      Thanks. We're aware of this inconvenience.
      The biggest offender here is gensym() and we are working on making future SDK versions more const-aware. The interim solution is to modify the SDK as you have done, or to define a macro or inline function that you can use as a substitute for the functions like gensym. E.g.:
      inline t_symbol* my_gensym(const char* s)
          return gensym((char*)s);
    • Nov 14 2012 | 2:47 am
      Hi Tim,
      it seems that this issue is back with the Max 6.0.4 SDK, at least with gensym_tr(), str_tr() and sprintf_tr(). I'll let you know if I find more.
      Cheers, Ádám
    • Nov 21 2012 | 12:04 pm
      Thanks -- I'll try to make sure I plug those holes... Tim
    • Jan 02 2013 | 11:50 am
      Hi Tim,
      I think that I've found another two: table_get() and table_dirty().
      Cheers, Ádám
    • Jul 23 2013 | 2:08 pm
      Hi Tim,
      just updated to SDK 6.1.3 and noticed that table_get() and table_dirty() was `fixed back' (or perhaps I modified them manually in an earlier SDK). Anyway, it seems that they're expecting t_symbol * instead of const t_symbol *.
      Cheers, Ádám
    • Jul 23 2013 | 2:16 pm
      Hi -- not sure I understand the problem... These are t_symbol* rather than char*. Can you provide the warning or error that the compiler is giving you?
      Thanks, - .. --
    • Jul 23 2013 | 4:30 pm
      it turns out that I messed up something during the upgrade process. Of course, due to the usage of C74_SYM_LINKER_FLAGS, the problem no longer happens in Max 6. However, in Max 5, the following code:
      const t_symbol * bufferName;
      long **          data;
      long             size;
      table_get ( bufferName, & data, & size );
      will cause a compiler error: invalid conversion from 'const t_symbol*' to 't_symbol*'.
      Cheers, Ádám
    • Jul 25 2013 | 1:40 pm
      Looks like you will need to do a cast to throw away the constness in this call.
      table_get ( (t_symbol*)bufferName, & data, & size );