Author Topic: enum (C) and autolist questions  (Read 3957 times)

phil-t

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
enum (C) and autolist questions
« on: February 10, 2009, 01:04:58 PM »
After being so spoilt by C# and Visual Studio for a few months, I'm back to embedded programming (in C) and using SlickEdit.

I've got a few questions about enumerations and auto list etc.. (SlickEdit 13.0.1.0)

1. typedef of 'enum' directly doesn't auto list.
Code: [Select]
typedef enum
{
    OPTION_1 = 0x01,
    OPTION_2 = 0x02
}te_My_Enum;
When I use the type in some code..
Code: [Select]
    te_My_Enum e_Var =
No auto list appears..

If I change the enum definition to
Code: [Select]
enum te_My_Enum_Enumeration
{
    OPTION_1 = 0x01,
    OPTION_2 = 0x02
};
typedef enum te_My_Enum_Enumeration te_My_Enum;

then
Code: [Select]
    te_My_Enum e_Var =
Will bring up the list of enum values.


2. Auto List enum param.
if I declare a parameter as an enum, when I call that function, is there anyway to get SlickEdit to autolist the enum values ?

e.g.
Code: [Select]

enum te_My_Enum
{
    OPTION_1,
    OPTION_2
};

void func(enum te_My_Enum e_Value);

...

{
    func([In an ideal world Autolist enum values here])
}


Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: enum (C) and autolist questions
« Reply #1 on: February 13, 2009, 11:49:54 AM »
Try Slick 13.0.2  - it handles the enum typedef ok for me.  For problem number 2, when the cursor is between the parentheses of the function call, you can press Alt-, (bound to function-argument-help) and you get the list of enum values - in 13.0.2.

Graeme

thefrogger

  • Community Member
  • Posts: 38
  • Hero Points: 2
Re: enum (C) and autolist questions
« Reply #2 on: February 17, 2009, 07:52:13 AM »
Note also that it's valid to name the enum using the same name as the type, as in:

Code: [Select]
typedef enum te_My_Enum
{
    OPTION_1 = 0x01,
    OPTION_2 = 0x02
}te_My_Enum;

You may not need to do this if 13.0.2 works out for you, but I find the construct useful, especially for structs. If you get into circular definition problems, you can always interchange the usage of:

Code: [Select]
te_My_Struct e_Var;
struct te_My_Struct e_Var;