07-24-2017 07:52 AM
Helpplease:
Someone will be kind enough to help me fix this problem?
Thant you
07-24-2017 08:33 AM
hello
your problem is in the h file where you declered the structure of the 'index' variable
07-24-2017 08:36 AM
Thank you
Here is how I declared it in h
07-24-2017 10:44 AM - edited 07-24-2017 10:46 AM
That's not a structure: it's an enumeration.
You can declare it as an int in the function definition (you are already using it as an int when you write Bench_Info_Item[index])
Additionally, you should initialize the enum:
typedef enum { No_Item = 0, Bench_Name, Bench_Number, ... } BenchInformationIndex;
07-25-2017 03:23 AM
Be extremely careful when using enums as array indices. Code like Bench_Info_Item[index-1] with index==0 might not be caught by the compiler and may only surface during debugging runs. Or the program works as expected but every now and then it does something weird.
Also: adding, and thus renumbering, the enum with No_Item=0 might cause issues if the enum is used to reference ring control entries or other things. Or somewhere else there's a hard coded Bench_Info_Item[0]=...
Clang has many warnings for enum issues but it's not bullet proof.
As a side note, taken from a C89 draft:
[...]
If the first enumerator has no = , the value of its enumeration constant is 0. Each subsequent enumerator with no = defines its enumeration constant as the value of the constant expression obtained by adding 1 to the value of the previous enumeration constant.
[...]
Each enumerated type shall be compatible with an integer type; the choice of type is implementation-defined.
08-04-2017 05:52 AM
Thanck you!