SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: joecar on March 30, 2018, 04:49:42 PM

Title: Nested struct definitions...
Post by: joecar on March 30, 2018, 04:49:42 PM
Usage of a struct defined within another struct is still highlighting as unknown symbol...

For example:

Code: [Select]
struct hw {
. . .
struct fwdt {
void *template;
ulong length;
ulong dump_size;
} fwdt[2];
. . .
};

see usage of struct fwdt in attached pic (highlighted as unknown symbol);

struct fwdt is defined only within struct hw and not defined anywhere else.


(* notice multiple name spaces *)

I'm using GNU C (gcc).

SE version 22.0.2.1 64-bit with hotfix_se2202_3_cumulative.



Title: Re: Nested struct definitions...
Post by: joecar on March 30, 2018, 05:53:17 PM
Here is another example:

Code: [Select]
struct qos_fcport_table {
uint16_t version;
. . .
struct qos_fcport_table_row {
uint8_t wwpn[8];
. . .
} table[];
} __packed;

struct qos_fcport_table_row  is defined within struct qos_fcport_table (not anywhere else)...

Title: Re: Nested struct definitions...
Post by: joecar on August 30, 2018, 05:01:16 PM
Just to let you know that this still happens in v23.0.0.3

Screenshots of two instances attached (unknown symbols are in yellow highlight)

The definition of struct fwdt is embedded within another struct;
same with definitions of struct qos_fcport_table and struct qos_fcport_row, they are embedded within another struct.

I'm using GNU C.

The code compiles/runs ok.


Title: Re: Nested struct definitions...
Post by: Dennis on August 30, 2018, 10:42:57 PM
I'll file a defect against this one.  This is a really ugly ANSI-C case, where you are using the same name in three different ways in close proximity.
Title: Re: Nested struct definitions...
Post by: Dennis on August 30, 2018, 10:47:10 PM
Actually, not filing a defect report.  These examples work correctly, provided you are in ANSI-C mode.

Document > Select Mode > ANSI-C

Do this for all your ANSI-C or K&R C files, you might want to point the "c" and "h" extensions at ANSI-C.

Then rebuild your workspace tag file.
Title: Re: Nested struct definitions...
Post by: joecar on September 06, 2018, 04:41:16 PM
Ok, thanks, I will set doc mode to ANSI C.
Title: Re: Nested struct definitions...
Post by: joecar on September 06, 2018, 04:43:25 PM
Is there a way to do this for the whole project/workspace, or all .c/.h files in bulk/batch...?
Title: Re: Nested struct definitions...
Post by: Clark on September 06, 2018, 05:51:41 PM
If you have not already made .c and .h use ANSI-C instead of C/C++ mode do the following

* Close all your files.
* go to Tools>Options>Languages>Application Languages>ANSI-C>General.
* Click on the Edit These Extensions... button. Add c and h.

Now when you open .c and .h files, they should be in ANSI-C mode. There are ways this can fail but hopefully closing your open files first will help. Workspace auto-restore information (.vpwhist and .vpwhistu) stores the mode name (seems like we can improve this to only store it if it's been overridden). Also, perfile.xml in your config directory can store the mode name (it's smart about it).
Title: Re: Nested struct definitions...
Post by: joecar on September 07, 2018, 10:50:55 PM
Ok, I'll try this, thanks.
Title: Re: Nested struct definitions...
Post by: joecar on October 09, 2018, 05:48:05 PM
In Beta 6 the ANCI-C document type has disappeared.


Anyway, I tried what you said above (last month) with ANSI-C and it made no difference (still got/get unknown symbol highlighting) (I've now selected GNU C/C++);

however, when you do Goto Definition, it takes you to the correct place in the struct...

i.e. it is only the unknown symbol highlighting that is incorrect.


Title: Re: Nested struct definitions...
Post by: Dennis on October 09, 2018, 05:51:17 PM
You are saying that ANSI-C is not in the list you go to Document > Select Mode... ?
Title: Re: Nested struct definitions...
Post by: joecar on October 09, 2018, 06:46:54 PM
I went back and checked again, and now I see ANSI-C...  :-[  I don't what happened prior...? 
Title: Re: Nested struct definitions...
Post by: joecar on October 09, 2018, 07:02:24 PM
Ok, I'm all better now...   ;D

I was able to set the document mode to ANSI-C (using Beta 6) for all source files, and now the unknown symbol highlighting is working properly (has gone away for nested structs)

( I had to retag the kernel include files so that those symbols would be defined )


Thanks, I appreciate all your help.
Title: Re: Nested struct definitions...
Post by: Dennis on October 09, 2018, 07:31:50 PM
No problem, glad you have things in order now.  It is a shame that some C++ code adopted ".c" and ".h" as file extensions, so we can't simply treat them as ANSI-C by default.  But, given the trade-offs, it is much more compatible for us to treat them as C++ out of the box.
Title: Re: Nested struct definitions...
Post by: joecar on October 10, 2018, 01:56:26 AM
I understand.