koverstreet / bcachefs

Other
662 stars 70 forks source link

compile error with clang in opts.c macro [b677b15] #578

Closed jpsollie closed 1 year ago

jpsollie commented 1 year ago

I'm not sure whether this error is due to a clang bug or the preprocessor macros not being 100% compliant:

when compiling with clang-16.0.5:

  CC [M]  fs/bcachefs/opts.o
  AR      fs/built-in.a
fs/bcachefs/opts.c:225:2: error: initializer element is not a compile-time constant
        BCH_OPTS()
        ^~~~~~~~~~
fs/bcachefs/opts.h:341:11: note: expanded from macro 'BCH_OPTS'
          OPT_FN(bch2_opt_fix_errors),                                  \
                 ^~~~~~~~~~~~~~~~~~~
fs/bcachefs/opts.c:209:48: note: expanded from macro 'OPT_FN'
#define OPT_FN(_fn)             .type = BCH_OPT_FN, .fn = _fn
                                                          ^~~
fs/bcachefs/opts.c:222:3: note: expanded from macro 'x'
                _type                                                   \
                ^~~~~
1 error generated.
make[3]: *** [scripts/Makefile.build:252: fs/bcachefs/opts.o] Error 1
make[2]: *** [scripts/Makefile.build:497: fs/bcachefs] Error 2
make[1]: *** [scripts/Makefile.build:497: fs] Error 2

I'll try to find a workaround and check whether other clang versions also sffer from the same problem

koverstreet commented 1 year ago

All the clang errors and warnings should be fixed now