Author Topic: Typedef structs not expanding  (Read 8716 times)

dunkers

  • Senior Community Member
  • Posts: 607
  • Hero Points: 28
Typedef structs not expanding
« on: September 07, 2006, 12:40:01 am »
If one has the following sort of code, when the cursor is on an appropriate variable the symbol window doesn't show the detail:

Code: [Select]
typedef struct
{
   int    someInt;
} SomeStruct_t;

SomeStruct_t *anInstance;

If one clicks on SomeStruct_t then the symbol window shows:

Code: [Select]
struct   SomeStruct_t   c:\somefile.c:4
typedef SomeStuct_t    c:\somefile.c:4

If one then right clicks in the symbole window and navidates to Data Types then unticks Typedefs the structure detail is shown as expected. Similarly, if one unticks Classes and Structs the typedef detail is shown.

Perhaps SE could have some intelligence added to cope with this combination? Other combinations (such as, for instance, typedef enum) appear to work OK.

« Last Edit: September 07, 2006, 12:41:47 am by dunkers »

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2747
  • Hero Points: 420
Re: Typedef structs not expanding
« Reply #1 on: September 07, 2006, 04:12:00 pm »
This problem was fixed in the 11.0.2 patch.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2747
  • Hero Points: 420
Re: Typedef structs not expanding
« Reply #2 on: September 07, 2006, 04:18:40 pm »
Oh, wait, I misread.  A related problem was fixed in 11.0.2, really.  :)

Turning off "typedefs" in the symbol window is a very viable workaround for you, because even if you turn off typedefs, if a symbol resolves to just a typedef, the symbol window will still show it, even with typedef's off.  It only effects filtering out duplicates.

I will file a change request to filter out anonymous symbols in the symbol window.

dunkers

  • Senior Community Member
  • Posts: 607
  • Hero Points: 28
Re: Typedef structs not expanding
« Reply #3 on: September 07, 2006, 04:35:13 pm »
Ah, thanks for the workaround :)

Er.. I have another similar problem with 11.0.2 (I have the symbol window open permanently). For the Function filter I have Procedures ticked and Prototypes NOT ticked. However, some functions still show both the function and prototype info lines, so no detail is shown. I can supply a screencap if this doesn't make sense.

If I choose the Functions Only quick filter then that works fine. Obviously, I want more than functions, just no prototypes :)

I thought it might be related to the typedef issue, but various combination of using typedefs in the return type or parameters hasn't turned up any kind of pattern.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2747
  • Hero Points: 420
Re: Typedef structs not expanding
« Reply #4 on: September 07, 2006, 04:40:38 pm »
My guess is that there is something other than a function or prototype in the list, so we are showing all the duplicates.  That would explain why "Functions only" filters the way you want.

dunkers

  • Senior Community Member
  • Posts: 607
  • Hero Points: 28
Re: Typedef structs not expanding
« Reply #5 on: September 07, 2006, 06:02:14 pm »
Do you have any suggestion as to what I should be looking for? Only the function and prototype are listed - I presume that if there were something else it'd list that as well.

Ummm... it might be a kind of software heat fault. I just checked now and the bits it was doing this with last night are OK now. This is one reason why I haven't mentioned it before,  because when I go to replicate the problem I end up questioning whether I actually saw it or not. However, last night I closed and restarted SE several times just to make sure and the problem was persistent. Now, it looks oh so very innocent!

dunkers

  • Senior Community Member
  • Posts: 607
  • Hero Points: 28
Re: Typedef structs not expanding
« Reply #6 on: September 07, 2006, 11:55:10 pm »
I've found how to stop the function problem occuring. All the Variables section (Paramaters and Locals, Data Members, etc) must be unticked. If any of them are ticked then the problem re-occurs.

Another observation: if, when the problem is showing, I untick Procedures | Functions then the prototype line is shown in the symbol window. This is even with Prototypes unticked as well. However, if I click on a function that doesn't exhibit the problem, with Procedures and Functions unticked that now shows the func and proto lines in the symbol window instead of detail.

Clearly, the two (the function that's fine and the function that shows the problem) are being treated very differently, but there appears to be no functional difference to my eye.

[Later...]
Ah, I think I might've found something. The functions exhibit the problem appear to all have a single parameter which is a typedef. In other words, and referring to my previous post for the typedef ..er.. def, this will cause a problem:

Code: [Select]
void SomeFunc(SomeStruct_t *aStruct);
but this will not have a problem:

Code: [Select]
void SomeFunc(SomeStruct_t *aStruct, int anInt);
So... looks to me like it's something related to the typedef thing that start this thread.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2747
  • Hero Points: 420
Re: Typedef structs not expanding
« Reply #7 on: September 08, 2006, 02:44:12 pm »
Hmm, do some of the prototypes omit the formal parameter name, like this?
Code: [Select]
int SomeFunc(SomeStruct_t);

This is a fingernails-scratching-on-a-chalkboard annoying ambiguity in C, because that could be a declaration of a variable named "SomeFunc" and initialized to "SomeStruct_t".  Keep in mind that our parser doesn't do symbol analysis, without doing full preprocessing, you can't do symbol analysis anyway, so we don't know what "SomeStruct_t" is when we see it.

dunkers

  • Senior Community Member
  • Posts: 607
  • Hero Points: 28
Re: Typedef structs not expanding
« Reply #8 on: September 08, 2006, 03:33:15 pm »
Quote
do some of the prototypes omit the formal parameter name

No, never. I can sometimes be inconsistent, but not one of my functions in over 15 years has ever missed the parameter name. Not even accidentally :)

Quote
we don't know what "SomeStruct_t" is

I think I see what you're driving at, but why should having another parameter fix it?

Actually, more to the point, does this problem also show for you given the information I've posted?
« Last Edit: September 08, 2006, 03:35:49 pm by dunkers »

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2747
  • Hero Points: 420
Re: Typedef structs not expanding
« Reply #9 on: September 08, 2006, 06:20:13 pm »
Some C Trivia: This is a valid declaration with initializer expression:
Code: [Select]
int a(3);

Now:
Code: [Select]
int SomeFunc(SomeStruct_t *aStruct);

"SomeStruct_t * aStruct" could be a multiplicative expression.  Therefore the prototype is considered as a potential variable declaration.  If you have a second parameter, then the stuff in the parenthesis can not be an initializer expression, thus "SomeFunc" can not be a variable.

I am filing a defect report for the Symbol Window to simply treat prototypes that could potentially be variable declarations as prototypes.  This will be fixed in a future version of SlickEdit.

dunkers

  • Senior Community Member
  • Posts: 607
  • Hero Points: 28
Re: Typedef structs not expanding
« Reply #10 on: September 08, 2006, 09:47:35 pm »
Quote
This is a valid declaration with initializer expression

Ah. I completely missed that  :o

Quote
I am filing a defect report

Thank you very much :)