#Assign an Enum type to another with the same value

1 messages · Page 1 of 1 (latest)

loud harbor
#

Hello, I was writing a wrapper around Raylib's window config flags but I can't get to assign my wrapper in place of ConfigFlags enum even though both of them are c.int.


import rl "vendor:raylib"

WINDOW_FLAG:: enum c.int {
    VSYNC_HINT               = 6, 
    FULLSCREEN_MODE          = 1, 
    WINDOW_RESIZABLE         = 2, 
    WINDOW_UNDECORATED       = 3, 
    WINDOW_HIDDEN            = 7, 
    WINDOW_MINIMIZED         = 9, 
    WINDOW_MAXIMIZED         = 10,
    WINDOW_UNFOCUSED         = 11,
    WINDOW_TOPMOST           = 12,
    WINDOW_ALWAYS_RUN        = 8, 
    WINDOW_TRANSPARENT       = 4, 
    WINDOW_HIGHDPI           = 13,
    WINDOW_MOUSE_PASSTHROUGH = 14,
    MSAA_4X_HINT             = 5, 
    INTERLACED_HINT          = 16,    
}

WINDOW_FLAGS :: distinct bit_set[WINDOW_FLAG; c.int]

and when I do
rl.SetConfigFlags(WINDOW_FLAGS.WINDOW_RESIZABLE)
I get the error
Cannot assign value 'WINDOWS_FLAGS.WINDOW_RESIZABLE' of type 'WINDOW_FLAGS' to 'ConfigFlags' in argument

vale dagger
#

You will need a cast. That is part of the whole "distinct typing" thing.

quick sonnet
quick sonnet
loud harbor
quick sonnet
loud harbor
quick sonnet