Providing a value for listing in a structure in C

I have the following structure defined in the header file that I cannot edit (not allowed):

struct Programma
{
enum {SERIE, FILM} programmaType;

char* titel;
char* zender;

time_t start;
time_t einde;

char* review;

union 
{
    Serie* serie;
    Film* film;
} typeData;
};

I tried:

Programma asd;

asd.programmaType = SERIE; //Error: identifier 'SERIE' is undefined
asd.programmaType = 0; //Error: a value of type 'int'cannot be assigned to an entity of type 'enum PRogramma::<unnamed>

and in a function with a pointer to the Programma structure as a parameter replacing '.' by '->', which gave me the same errors.

I think I am doing the same thing as suggested here ( How to use enumeration inside a structure in ANSI C? ), But I can not stop getting random errors.

EDIT: For some reason in Visual Studio, when I print asd. A regular drop-down list appears, but there is an option for "Typedata", as well as "SERIE" and "FILM". Personally, I think that something is wrong with the declaration of the structure, but it was given, and I should not edit it.

EDIT EDIT: ++ Visual Studio 2008, .h, .c. , "C", , .

+5
4

, , C, ++. scoping ::,

asd.programmaType = Programma::SERIE;
+5

C, ( typedef) .

Try:

struct Programma asd;
+3

replace

Programma asd;

by

struct Programma asd;

then asd.programmaType = SERIE;must be accepted.

+1
source

Try

asd.programmaType = Programma::SERIE;
0
source

All Articles