accre / lstore

LStore - A fault-tolerant, performant distributed data storage framework.
http://www.lstore.org
Apache License 2.0
4 stars 5 forks source link

Handle anonymous unions #82

Closed PerilousApricot closed 8 years ago

PerilousApricot commented 8 years ago

Anonymous unions like

struct tbx_pack_t {                                                                
    int type;                                                                      
    int mode;                                                                      
    union {                                                                        
        tbx_pack_raw_t raw;                                                        
        tbx_pack_zlib_t zlib;                                                      
    };
}

Don't exist in standard C until C11 and compiler support for that particular C11 feature in GCC is past most existing distros, so adding -std=c99 or -std=c11 breaks things. GCC supports the extension -fms-extensions to re-enable the code in standards-compliant mode.

We should either:

PerilousApricot commented 8 years ago

This blocks #83

tacketar commented 8 years ago

It's really just a problem in the short term. Since it's now part of the standard everyone will support it next year. I'd vote to leave things as they are since it's automatically fixed with time.

PerilousApricot commented 8 years ago

Not quite:

  • You can't compile at all with -std=anything, so we can't just wait for attrition
  • Older distros won't update their compilers to new major revisions, just point bug fixes, so the problem won't just evaporate (centos-6's EOL is 2022, IIRC)

It's dark in this basement.

tacketar commented 8 years ago

They aren't used a lot but there's an elegance to them that naming them destroys. I've used anonymous unions for decades (C, Fortran, Cobol, Pascal) that's why I'm surprised they are a recent addition to the standard. Is there any way to tweak the build settings for the old compilers?

I assume this would also mean we couldn't use C11 atomic types due to lack of support in pre-C11 compilers.

PerilousApricot commented 8 years ago

Tweaking the compiler settings was the 3rd thing I listed :). Though, I'd really prefer to stick to standard C. It may be less elegant, but supporting a matrix of compilers-specific workarounds is something I'm less in favor of.

And yes, the compiler support matrix crimps using builtin C11 atomic intrinsics.

It's dark in this basement.

PerilousApricot commented 8 years ago

Fixed by #86