SlickEdit Community
SlickEdit Product Discussion => SlickEdit® => Topic started by: rowbearto on January 13, 2022, 04:11:06 pm
-
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.
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.
-
Looks like I'm able to load if I add at the top:
#import "se/tags/TaggingGuard.e"
-
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.
-
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?
-
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.