42School / norminette

Official 42 norminette
MIT License
956 stars 140 forks source link

Union/Struct/Enum Definitions Inside a Function Scope #437

Closed yumamur closed 11 months ago

yumamur commented 1 year ago

Well, that one is a bit complicated in the context of the Norm.

enum e_endian
{
    LITTLE,
    BIG
};

enum e_endian   which_endian(void)
{
    union
    {
        unsigned char   var2[2];
        unsigned short  var1;
    }   u_endian;// This should be the correct indentation
//  }                   u_endian; 
    u_endian.var1 = 1;
    if (u_endian.var1 == u_endian.var2[0])
        return (LITTLE);
    else
        return (BIG);
}

I assume that the indentation and the alignment of the union should be as it is. Not sure of it's name's though. It returns many errors, and a variable scope inside a function breaks norminette.

matthieu42Network commented 1 year ago

Hello, union is not allowed inside the scope of the fonction, but it needs to return a clear error.

yumamur commented 1 year ago

I forgot about that, thanks.