Author Topic: Color coding quirk - C++ __declspec(xx)  (Read 3348 times)

skywise

  • Senior Community Member
  • Posts: 331
  • Hero Points: 10
Color coding quirk - C++ __declspec(xx)
« on: October 24, 2012, 05:51:22 pm »
SE 17.0.2 - brief keymode, win7 x64-
I'm working on some code that has a #define to handle windows DLLs -
IE
Code: [Select]
// someheader.h
#ifdef BUILD_MYLIB
     #define MYLIB __declspec(dllexport)
#else
     #define MYLIB __declspec(dllimport)
#endif

I've added MYLIB to the projectname_cpp.h file so it'll be colored correctly-
Now if I do something like:

Code: [Select]
MYLIB void DoSomething()
MYLIB is colored correctly as a "definition" and can be right clicked on and go to the definition.

But if I code it as:
Code: [Select]
class MYLIB SomeClass
{
//blah
};

MYLIB is *not* properly detected by the colorizer and appears red (Symbol Color: Symbol not found) - but I can right click on it and go to the definition.

Curious, I tried playing with this by removing the #define and just placing __declspec(dllexport) directly into the code.

In both cases:
Code: [Select]
class __declspec(dllexport) SomeClass
{
//blah
};
//and
__declspec(dllexport) void DoSomething();
__declspec(dllexport) showed as Symbol not found.  Right clicking on it and going to the definition resulted in an error.

I've verified that __declspec(typename) is still set in the C++ preprocessor options (I believe that's a default define - It's blank but it's defined).

Any ideas?

Alf

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
Re: Color coding quirk - C++ __declspec(xx)
« Reply #1 on: November 05, 2012, 09:17:13 am »
The same color coding problem appears in Java. Even for symbols declared within a function. Almost every line in the source is marked as "Symbol not found"!
« Last Edit: November 05, 2012, 09:19:58 am by Alf »

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3434
  • Hero Points: 465
Re: Color coding quirk - C++ __declspec(xx)
« Reply #2 on: November 06, 2012, 02:46:43 pm »
@skywise
The context tagging logic is getting tripped up the fact that "MYLIB" is directly preceded by the "class" keyword, so we are specifically looking for a class name when looking for that identifier.  Technically, yeah, that is a bug, just a really annoying one to fix because it subverts a really nice optimization in the symbol lookup code.

@Alf
You use preprocessing in Java?  On every line of the file?  You really need to post an example, and since it is a different language and a very different test case, a separate thread would be appropriate.

Alf

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
Re: Color coding quirk - C++ __declspec(xx)
« Reply #3 on: November 06, 2012, 02:56:04 pm »
Dennis:
A case about this is created for your support: CAS-59571-ZSGG.
There are attached screen captures.