Can an enumeration have a limited scope if it is defined inside the structure in c

I want to know if it is possible to limit the enumeration in how to access it by placing it inside the structure. I know this will work in C ++ (where I got this idea), but I don't know if this will work in c. So for example, if I have two different structures

struct SaticArrayA
{
    enum { MAX_SIZE = 10 };
    int array[MAX_SIZE];
};
struct SaticArrayB
{
    enum { MAX_SIZE = 20 };
    int array[MAX_SIZE];
};

Will it even be close to compiling? Basically, I want to do what I would do in C ++ and give myself a general naming convention in the “classes” so that I can ask any array about what size it is, etc.

(ps I essentially try to give myself a better static array in c that will not lose size information (by decomposing into a pointer), the second one I'm trying to pass to another area).

+4
1

,

enum { MAX_SIZE = 10 } name ;

MAX_SIZE

C11 :

6.2.1. p7 , , , . , . ,

, , .

.

, , , , , .

+5

All Articles