Author Topic: Symbol completion for inlined static fct.s ?  (Read 11369 times)

hs2

  • Senior Community Member
  • Posts: 2725
  • Hero Points: 280
Symbol completion for inlined static fct.s ?
« on: May 09, 2007, 12:18:21 am »
Hello SlickTeam:

Is there a way to get symbol completion even for this use case ?
The static fct.s are not listed on <ALT-DOT> though they are #include'd for inlining and hence 'visible'.
I know it might not be easy ... but hey - you are the SlickTeam :)

@see e.g. <linux kernel 2.6.x>/include/asm-powerpc/atomic.h:
atomic.h
Code: [Select]
static __inline__ void atomic_dec(atomic_t *v)
{
   ....
}
static __inline__ void atomic_dec_return(atomic_t *v)
{
   ....
}

file.c
Code: [Select]
   ....
   atomic_d<cursor here -> ALT-DOT>

Edit:
push-tag works of course.
What about considering static fct.s as globally visible/completable when defined in a header file ?

Thanks a lot,

HS2
« Last Edit: May 09, 2007, 12:23:42 am by hs2 »

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2049
  • Hero Points: 251
Re: Symbol completion for inlined static fct.s ?
« Reply #1 on: May 11, 2007, 04:26:00 pm »
There will be a better workaround for this in 12.0.1, but in your case, a temporary solution is to define __inline__ in your C Preprocessing setup, but DO NOT make it #define to "inline", make it empty.

hs2

  • Senior Community Member
  • Posts: 2725
  • Hero Points: 280
Re: Symbol completion for inlined static fct.s ?
« Reply #2 on: May 12, 2007, 07:28:47 am »
@Dennis:
No way - the only workaround to get symbol information was to remove 'static' from the inline fct. definition (atomic.h) :(
And there is no difference whether __inline__ is #define'd or not.

Amazingly this IS working (but obviously NOT applicable):
atomic.h:
Code: [Select]
__inline__ void atomic_dec_g(atomic_t *v)
{
   ....
}

And this is NOT working:
Code: [Select]
static void atomic_dec_s(atomic_t *v)
{
   ....
}
static __inline__ void atomic_dec_si(atomic_t *v)
{
   ....
}

See attached my vsparser header for the compiler (GNU proj) I'm using.
Maybe I did sth. wrong when generating it.
BTW: The compiler is gcc 4.1.x based. I've no idea if the 'g++-common.h' is compatible.

Any better ideas ?

EDIT: ... Tried a few more things (don't ask).... still no luck.
I finally decided to add '#define static static' to 'usercpp.h' (which helped) but I don't think that this is reasonable solution.
Another surprise: Rebuild tag file after modifying the C Preproc. setup is useless. I had to retag all src files to make the changes there really take effect. Is this by design ?

HS2
« Last Edit: May 12, 2007, 08:27:31 am by hs2 »

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2049
  • Hero Points: 251
Re: Symbol completion for inlined static fct.s ?
« Reply #3 on: May 14, 2007, 02:22:31 pm »
My mistake.  I really shouldn't post after 1:00 on Fridays.  inline, __inline__, INLINE, whatever form it takes, doesn't make a difference.  It is the static keyword that breaks things, because static says the symbol is private to the module that it is located in (which in this case was a header file).  As you found, defining static in usercpp.h is a workaround, though not ideal (that's the C preprocessing setup I was talking about).  Like I said, 12.0.1 will have a new solution for handling this anatopism with the usage of static.

With respect to the tag file rebuilding, when you use the dialog to set up preprocessing, you will be prompted whether or not you want to rebuild your workspace tag file.  However, if you just modify usercpp.h directly, then all bets are off, as they should be.

hs2

  • Senior Community Member
  • Posts: 2725
  • Hero Points: 280
Re: Symbol completion for inlined static fct.s ?
« Reply #4 on: May 14, 2007, 03:21:53 pm »
@Dennis: In fact I used the dialog to setup the magic 'static' bullet. That's the reason why I'm asking.
It seems that a plain rebuild doesn't consider 'usercpp.h' as dependency.
If the C-PP setup was changed by the user, every srcfile should be retagged anyway, right ?
Except you check the given #defines against the #defines contained/used (even indirectly) in the srcfiles.
But this is too expensive (read, slow)...

BTW: When I skip the default procedures I know that this could break things and I'm try to be careful ;)

HS2

hs2

  • Senior Community Member
  • Posts: 2725
  • Hero Points: 280
Re: Symbol completion for inlined static fct.s ?
« Reply #5 on: May 25, 2007, 10:35:40 pm »
Hello Dennis,

what's the meaning if this ;)
Quote
* Tagging functionality has been added to differentiate between compilation units and header files when handling the static keyword.

Symbol completion is still not working w/o the add. CPP setting mentioned before and push_tag was already working v12.0.0.
What's the new thing I'm obviously missing ? (removed the CPP 'static' - rebuilt the tagfile and also retagged all srcs - and finally re-added CPP 'static')
However, I'd appreciate if you could have a look at it.

Thanks,

HS2
« Last Edit: May 25, 2007, 10:49:53 pm by hs2 »

hs2

  • Senior Community Member
  • Posts: 2725
  • Hero Points: 280
Re: Symbol completion for inlined static fct.s ?
« Reply #6 on: June 06, 2007, 08:20:38 pm »
Sorry for ping'ing, but I really would like to know what I'm doing wrong here or what I'm missing.
Is there anybody who could answer that please ?

Thanks,
HS2

PS: Are there any news regarding http://community.slickedit.com/index.php?topic=1553.msg6685#msg6685 ?

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2049
  • Hero Points: 251
Re: Symbol completion for inlined static fct.s ?
« Reply #7 on: June 22, 2007, 07:49:31 pm »
In 12.01, the way we tell a compilation unit from a header file for this particular case is by looking at the file extension.  If your header file doesn't end with 'h', 'i', or (ughhh), extensionless, the new workaround will not work for you.

Otherwise, send in a complete example to support with directions on specifically what is failing, maybe your use case is different from my test case?

hs2

  • Senior Community Member
  • Posts: 2725
  • Hero Points: 280
Re: Symbol completion for inlined static fct.s ?
« Reply #8 on: June 22, 2007, 08:02:34 pm »
Sorry Dennis - I re-tried it again ( ...removed the CPP 'static' - rebuilt the tagfile ...) and it's ok now ???
I've absolutely no idea why it wasn't working when I tested it 1st time...
So just forget it.

Sorry again and thanks a lot,
HS2

hs2

  • Senior Community Member
  • Posts: 2725
  • Hero Points: 280
Re: Symbol completion for inlined static fct.s ?
« Reply #9 on: July 21, 2007, 04:26:22 pm »
@Dennis: Unfortunately it's still not perfect ...
Only autocomplete is ok thanks to your changes, but list-symbols still can't handle that.

file.h
Code: [Select]
#define atomic_read(v)        ((v)->counter)
static __inline__ void atomic_add(int a, atomic_t *v)
{
}
file.cpp:
Code: [Select]
#include "file.h"
...
atomic_<cursor here -> list-symbols>
...

Only 'atomic_read' is shown (as #define) in 'Globals:', but as mentioned autocomplete shows both (the #define and the fct.).
So I'm going to add '#define static static' to the CPP setup again to get consistent behaviour of both features.

HS2

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2049
  • Hero Points: 251
Re: Symbol completion for inlined static fct.s ?
« Reply #10 on: July 25, 2007, 08:49:58 pm »
Indeed, this was an oversight, thanks for detecting this mistake.  I am handing over a windows-only hot fix for this issue to our support group as we speak.

hs2

  • Senior Community Member
  • Posts: 2725
  • Hero Points: 280
Re: Symbol completion for inlined static fct.s ?
« Reply #11 on: July 25, 2007, 09:03:49 pm »
Oh great - thanks a lot Dennis !
Should I contact support to get it or do they put it on the hotfix webpage ?

HS2

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2049
  • Hero Points: 251
Re: Symbol completion for inlined static fct.s ?
« Reply #12 on: July 25, 2007, 09:15:30 pm »
Contact support to get it.

hs2

  • Senior Community Member
  • Posts: 2725
  • Hero Points: 280
Re: Symbol completion for inlined static fct.s ?
« Reply #13 on: August 01, 2007, 02:55:17 pm »
@Dennis: Believe it or not it's not longer working - I can't believe it :(
How could I get into that situation ? I've not the slightest idea...
It's the same project and I'm not aware that I did something that could cause this.
E.g. the 'atomic_add' is correctly displayed EVERYWERE (where tags can be viewed) but it's NOT shown by 'list-symbols' (anymore ?).
I don't really want to add '#define static static' to the CPP setup AGAIN ... but maybe I do and leave it there b/c that was always working (somehow).

What else can I do ?

HS2
« Last Edit: August 01, 2007, 03:11:20 pm by hs2 »

hs2

  • Senior Community Member
  • Posts: 2725
  • Hero Points: 280
Re: Symbol completion for inlined static fct.s ?
« Reply #14 on: August 01, 2007, 03:11:08 pm »
@Dennis: One more question: Should I add '#define __inline__ inline' to the CPP setup ?
Without that it wasn't recognized by the Tagprops TB, although 'autocomplete' knows about it being a keyword (from the lexer setup I guess).
I know that all these compiler extensions (?) must be a nightmare (@see __a_s_m__). But it's used in real world software...
However, it's ok to 'resolve' these extensions by adding an appropriate #define to the CPP setup. Works.
What's your suggestion ?

HS2