jackaudio / jack1

jack1 codebase
Other
250 stars 70 forks source link

Variable name "register" causes compiler error on C++17 #84

Closed mgeier closed 3 years ago

mgeier commented 5 years ago

On Travis-CI, using Xcode-10.1 with Apple LLVM version 10.0.0 (clang-1000.11.45.5), I get the compile error:

/usr/local/Cellar/jack/0.125.0_3/include/jack/types.h:389:71: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
typedef void (*JackPortRegistrationCallback)(jack_port_id_t port, int register, void *arg);
                                                                      ^~~~~~~~
/usr/local/Cellar/jack/0.125.0_3/include/jack/types.h:411:70: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
typedef void (*JackClientRegistrationCallback)(const char* name, int register, void *arg);
                                                                     ^~~~~~~~

The reason seems to be that the register storage class specifier has been removed in C++17, see https://en.cppreference.com/w/cpp/language/storage_duration.

JACK1 doesn't really want to use that anyway, but it tries to use register as a variable name, which causes the error.

This happens in the file types.h in https://github.com/jackaudio/headers, which is included as a submodule in this repo.

typedef void (*JackPortRegistrationCallback)(jack_port_id_t port, int register, void *arg);
typedef void (*JackClientRegistrationCallback)(const char* name, int register, void *arg);

It can even be seen in the syntax highlighting that register is somehow special ...

JACK2 already took care of this problem in https://github.com/jackaudio/jack2/blob/master/common/jack/types.h:

typedef void (*JackPortRegistrationCallback)(jack_port_id_t port, int /* register */, void *arg);
typedef void (*JackClientRegistrationCallback)(const char* name, int /* register */, void *arg);