SlickEdit Community

SlickEdit Product Discussion => SlickEditĀ® => Slick-CĀ® Macro Programming => Topic started by: marksun on May 31, 2013, 02:41:48 am

Title: Adding members to a struct is causing Invalid argument for existing memebers.
Post by: marksun on May 31, 2013, 02:41:48 am
I'm hitting a weird case where I can't add a new member to a struct in my macro.  This repros for me in 17 and 18 beta 4.
The following reduced macro code will load, but if I add an int to the top of the SymColour struct (ie int m_foo;), then I'll suddenly get an Invalid argument during _InitSymColour and Find Slick-C error says that m_rgb is now wrong.  Any ideas as to what's going wrong?

Code: [Select]
#include "slick.sh"
#import "main.e"
#include "markers.sh"


struct SymColour
{
   int m_ColourSymHighlight;
   int m_cRef;    // used for delayed color creation and selection.
   int m_rgb;
} s_symColour[];


static void _InitSymColour()
{
   s_symColour[0].m_ColourSymHighlight = -1;
   s_symColour[0].m_rgb = _rgb(0xff, 0xff, 0x00);
   s_symColour[0].m_cRef = 0;
}


static void DeferredInitSymHighlight()
{
   
   if ( !pos( "-mdihide", _editor_cmdline, 1, 'i' ) )
   {
      _InitSymColour()
   }
}

definit()
{
   _post_call( DeferredInitSymHighlight );
}
Title: Re: Adding members to a struct is causing Invalid argument for existing memebers.
Post by: chrisant on May 31, 2013, 04:02:28 am
s_symColor is declared as a global variable whose value persists between editor invocations, so its scope extends outside the module.  That may be involved somehow.

If it doesn't need to be persisted or used outside the macro, then declaring it with the "static" keyword might help.
Title: Re: Adding members to a struct is causing Invalid argument for existing memebers.
Post by: marksun on May 31, 2013, 04:58:45 am
Thanks Chris.  I figured it had to be something I was doing wrong.