Shoutbox

small mistake in C template? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: small mistake in C template? (/showthread.php?tid=25770)

small mistake in C template? by Whacko on 05-23-2004 at 02:01 PM

Patchou... I hope you get this ;)

i found this in your  MPPluginHeader.h

code:

MPPLUGIN_RETURN_VOID DisplayToast(/*[in]*/  const char* sMessage,
                                  /*[in]*/  const char* sTitle,
                                  /*[in]*/  const char* sProgram,
                                  /*[in]*/  bool bPlaySound)
{
    char sMessageSafe[256]; sMessage[255] = '\0';



the "sMessage[255] = '\0'; " is not allowed here as its defined as const. VC++ may not have problem with it, however Borland C++ wont compile because of it.

Its NOT a big deal, it can be easily changed to char* without the const, or a little workaround:

code:

MPPLUGIN_RETURN_VOID DisplayToast(/*[in]*/  const char* sMessage,
                                  /*[in]*/  const char* sTitle,
                                  /*[in]*/  const char* sProgram,
                                  /*[in]*/  bool bPlaySound)
{
  char *workaround;
    char sMessageSafe[256];
//  sMessage[255] = '\0';
  workaround = (char*) &sMessage[255];

  *workaround = '\0';




just wanted to let you know ;) let me know what you think ;)
RE: small mistake in C template? by oberststen on 05-23-2004 at 08:54 PM

VC++ have the same error, it can't compile any plug-in


RE: small mistake in C template? by Patchou on 05-24-2004 at 03:07 AM

bha, stupid me... I'll fix it in 2 minutes. Thank you :)


RE: small mistake in C template? by Choli on 05-24-2004 at 11:06 AM

quote:
Originally posted by TheBlasphemer
Wouldn't that cause an access violation!?!
so true
quote:
use this instead:
code:
if (lstrlen(sMessage)>255)
   sMessage[256]=0;


sMessasge[255]=0; ;)

a bit offtopic:
quote:
Originally posted by Patchou
bha, stupid me... I'll fix it in 2 minutes. Thank you :)
:O oh oh... always patchou says that he forgets about it and never fixes :mipdodgy:  vague patch...   j/k :P