Author Topic: const confusion: slickedit bug?  (Read 3122 times)

Ganesh Venkitachalam

  • Community Member
  • Posts: 32
  • Hero Points: 0
const confusion: slickedit bug?
« on: March 19, 2013, 09:47:24 PM »
I program in C, and we use const (especially with pointer types) extensively. This manages to confuse slickedit AFACIT, in the following way:

I have a (say) function parameter that looks like

void
bar(const my_cool_struct *s)
{
...
char c = s->c;
}

in the body, if I execute push_tag command with cursor over buf[0], cursor goes to the line "const my_cool_struct *s in the function param list - but the cursor actually ends up at "const", and *not* my_cool_struct. At the next push_tag (I want to see what my_cool_struct looks like), the push_tag fails with "Tag const not found".

Is there a workaround? Help!

Ganesh Venkitachalam

  • Community Member
  • Posts: 32
  • Hero Points: 0
Re: const confusion: slickedit bug?
« Reply #1 on: March 19, 2013, 09:48:16 PM »
Sorry - I meant "cusor over s->c", not "cursor over buf[0]".

TKasparek

  • Senior Community Member
  • Posts: 246
  • Hero Points: 29
Re: const confusion: slickedit bug?
« Reply #2 on: March 20, 2013, 06:12:57 PM »
To help clarify if I understand, you use:
Code: [Select]
struct your_cool_struct {
   var_type c;
};

void bar( const your_cool_struct *s )
{
   /* Other stuff */
   var_type c = s->c;
}

With this situation, I've come to expect it to automatically go to different declarations depending on the part of the 's->c' your cursor is on. If you want to go the where c is declared, I'll place the cursor on c and it'll go straight to the struct declaration. If I want to see the variable s, I place the cursor there and push-tag. AFAIK there is no way to automatically make SE jump to the s declaration and have the cursor on the declaring struct name so that another push-tag would automatically go to the struct declaration.

This would be nice though... feature request maybe?

Ganesh Venkitachalam

  • Community Member
  • Posts: 32
  • Hero Points: 0
Re: const confusion: slickedit bug?
« Reply #3 on: March 20, 2013, 06:34:28 PM »
Sorry for not being clear. I have my cursor over "s". If I don't have the const, when I push-tage on s, cursor goes to the word my_cool_struct on the param list, and a second push tag goes to the definition of my_cool_struct. If I use const, the first push_tag ends up with the cursor on the word const, and the second push-tag does not work.

i.e for me, the second push-tag does what it should do if I don't have the const qualifier..

TKasparek

  • Senior Community Member
  • Posts: 246
  • Hero Points: 29
Re: const confusion: slickedit bug?
« Reply #4 on: March 20, 2013, 11:04:32 PM »
Yeah, it always goes to the first letter of the variable type declaration. There was an error in the code I placed before. I was missing the struct in the foo function definition. Should have been:
Code: [Select]
struct your_cool_struct {
   var_type c;
};

void bar( const struct your_cool_struct *s )
{
   /* Other stuff */
   var_type c = s->c;
}
With the cursor on the s in the foo function, push-ref should bring you to const in the function header (or s in struct if const isn't there.) The only exception I've seen to this is with functions explicitly. If you quickly push-tag twice the first time will go to the implementation and the second goes to the prototype (if there are those two.) I believe there is an option for this but I can't remember where it is.

To get the functionality you want you would need a typedef in your code to define a new type as the struct. This seems like overkill to get the functionality that you want but...

Code: [Select]
typedef const struct some_struct_name {
   char c;
} your_cool_struct;

foo( your_cool_struct *s )
{
   s->c;
}

Ganesh Venkitachalam

  • Community Member
  • Posts: 32
  • Hero Points: 0
Re: const confusion: slickedit bug?
« Reply #5 on: March 20, 2013, 11:34:05 PM »
Thanks for verifying this.

No, my colleagues would kill me if I pollute the code to appease slickedit. Slickedit guys, can you please file a feature request "slickedit in C must understand const"? Thanks!

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: const confusion: slickedit bug?
« Reply #6 on: March 21, 2013, 06:41:26 AM »
You COULD add a '#define const' to your C/C++ Preprocession options basically hiding 'const' from the SE symbol parser, but beware that 'push-tag' behaves correctly when jumping to the beginning of the symbol defintion which comprises 'const' in your case.
Sure, there are bugs in SE but not as much as you might think or you're used to from other products ;)
Don't get confused if SE behaves a bit different than you'd expect at the first place.
HS2