Author Topic: Control 'TaggingGuard' must be declared or cannot be a member of non-struct/unio  (Read 378 times)

rowbearto

  • Senior Community Member
  • Posts: 2169
  • Hero Points: 132
A few years ago I wrote a macro that I'm trying to revive.

It had the below code in it.

When I try to load this macro I get error:

"Control 'TaggingGuard' must be declared or cannot be a member of non-struct/union/class type".

As it has been a few years since I wrote this I forgot many things.

Any clues on what I was trying to do here and how to get past this error?

The load error occurs on the line with '*' marked below.

Code: [Select]
            if (_istagging_supported(p_LangId))
            {
               m_update_context = true;
*              se.tags.TaggingGuard sentry;
               sentry.lockContext(false);
               _UpdateContext(true, true);
               tag_search_result_context_start(m_buf_id);
            }

I uploaded the full macro file, ext_code_browse.e, to support.

rowbearto

  • Senior Community Member
  • Posts: 2169
  • Hero Points: 132
Looks like I'm able to load if I add at the top:

Code: [Select]
#import "se/tags/TaggingGuard.e"

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3618
  • Hero Points: 481
That is the correct fix.

#import is like #include in C++ (but better).  First you do not need header guards, and second, it scans the imported module for declarations and definitions (treating function definitions like prototypes, skipping over function bodies).  Slick-C requires the #import to get the class definition and it's member functions.

rowbearto

  • Senior Community Member
  • Posts: 2169
  • Hero Points: 132
Thanks Dennis. This macro was working without that extra import in 2019. I suppose this TaggingGuard was moved to a new file that now needs import, but in 2019 it may have been in a different file that I had already imported?

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3618
  • Hero Points: 481
Between 2019 and 2021, I cleaned up a lot of cases where code was using #require incorrectly, so your theory is probably correct.  Glad it's working for you now.