enum error reported by the Keil compiler in SDK examples

4 posts / 0 new
Last post
brian
Offline
Last seen:5年11months ago
Expert Master
Joined:2014-10-16 18:10
enum error reported by the Keil compiler in SDK examples

In the template project one gets an error using the Keil compiler in gap.h here

/// Random Address type

enum gap_rnd_addr_type
{
/// Static random address
GAP_STATIC_ADDR = SMPM_ADDR_TYPE_STATIC,
/// Private non resolvable address
GAP_NON_RSLV_ADDR = SMPM_ADDR_TYPE_PRIV_NON_RESOLV,
/// Private resolvable address
GAP_RSLV_ADDR = SMPM_ADDR_TYPE_PRIV_RESOLV,
};

THis is a case where an enum is being delcared by another enum defined in smpm.h which is

/**
* Random Address Types
*/
enum smpm_rand_addr_type
{
/// Private Non Resolvable - 00 (MSB->LSB)
SMPM_ADDR_TYPE_PRIV_NON_RESOLV = 0 x00,
/// Private Resolvable - 01
SMPM_ADDR_TYPE_PRIV_RESOLV = 0x40,
/// Static - 11
SMPM_ADDR_TYPE_STATIC = 0xC0,
};

There error reported by the compiler is that the values in gap.h for the gap_rnd_addr_type enum are undefined. THis nested use of enums appears weird. Why is this happening and what can I do to resolve it. (Note this is not code I have written but was done by DS and/or RW. Thanks for a resolution.

Oh yes, the smpm.h header is included in the gap.h header.

MHv_Dialog
Offline
Last seen:1 week 3 days ago
Staff
Joined:2013-12-06 15:10
Not sure I understand the

Not sure I understand the issue. Are you saying that you are unable to compile the template_fh project code? I can compile it without issues.

brian
Offline
Last seen:5年11months ago
Expert Master
Joined:2014-10-16 18:10
It compiles unless I write

It compiles unless I write code that references the item with the error. I couldn't wait for an answer so I hard coded the enums and got rid of the error. I don't know the consequences.

klim9531
Offline
Last seen:4 years 3 months ago
Joined:2015-01-28 23:52
I see the problem described

I see the problem described above, in the proximity_fh project code as well as in the template where I first noticed it. Both compile and run fine. The valid question is: Even though there is a 'workaround' (hard code the enum values in the smpm.h file directly into the gap.h file), why are the references failing? Its bad practice to recklessly edit common code.