liuq / QuadProgpp

A C++ library for Quadratic Programming which implements the Goldfarb-Idnani active-set dual method.
MIT License
283 stars 88 forks source link

Remove "register" from public headers for C++17 #8

Closed yuki-koyama closed 6 years ago

yuki-koyama commented 6 years ago

Variable declaration with the register keyword was deprecated in C++11 and removed in C++17. https://en.cppreference.com/w/cpp/language/storage_duration

This means that, if a QuadProg++ user uses C++17, she cannot include the header QuadProg++/QuadProg++.hh in her codes in a standard way. To ignore register by overriding it, she may need to write something like:

#if __cplusplus >= 201703L
#define register
#endif

before she includes the header file, which is awkward.

I think there are two ways to solve this problem:

I suggest taking the former solution because it is often said that the register keyword is likely to be ignored by recent compilers (they could optimize codes better than humans).

Note that having register in .cc files is fine as it can be compiled using older C++. So I leave it as it is.

liuq commented 6 years ago

Thanks for your contribution.