Author Topic: Adding members to a struct is causing Invalid argument for existing memebers.  (Read 2375 times)

marksun

  • Community Member
  • Posts: 24
  • Hero Points: 5
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 );
}

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
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.

marksun

  • Community Member
  • Posts: 24
  • Hero Points: 5
Thanks Chris.  I figured it had to be something I was doing wrong.