Skip to content

Commit

Permalink
Use __declspec(noreturn) on Windows instead of [[noreturn]].
Browse files Browse the repository at this point in the history
MSVC doesn't support [[noreturn]] yet.
  • Loading branch information
joto committed Aug 25, 2014
1 parent 15d3dc7 commit 32b2331
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
5 changes: 1 addition & 4 deletions include/osmium/index/index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ namespace osmium {
namespace index {

template <typename TKey>
#ifndef _MSC_VER
[[noreturn]]
#endif
void not_found_error(TKey key) {
OSMIUM_NORETURN void not_found_error(TKey key) {
std::stringstream s;
s << "id " << key << " no found";
throw not_found(s.str());
Expand Down
8 changes: 3 additions & 5 deletions include/osmium/io/bzip2_compression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,20 @@ DEALINGS IN THE SOFTWARE.

#include <bzlib.h>
#ifndef _MSC_VER
#include <unistd.h>
# include <unistd.h>
#endif

#include <osmium/io/compression.hpp>
#include <osmium/io/file_compression.hpp>
#include <osmium/util/compatibility.hpp>

namespace osmium {

namespace io {

namespace detail {

#ifndef _MSC_VER
[[noreturn]]
#endif
inline void throw_bzip2_error(const std::string& msg, int error) {
OSMIUM_NORETURN inline void throw_bzip2_error(const std::string& msg, int error) {
throw std::runtime_error("bzip2 error: " + msg + ": " + std::to_string(error));
}

Expand Down
6 changes: 2 additions & 4 deletions include/osmium/io/compression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ DEALINGS IN THE SOFTWARE.

#include <osmium/io/detail/read_write.hpp>
#include <osmium/io/file_compression.hpp>
#include <osmium/util/compatibility.hpp>

namespace osmium {

Expand Down Expand Up @@ -120,10 +121,7 @@ namespace osmium {
CompressionFactory(CompressionFactory&&) = delete;
CompressionFactory& operator=(CompressionFactory&&) = delete;

#ifndef _MSC_VER
[[noreturn]]
#endif
void error(osmium::io::file_compression compression) {
OSMIUM_NORETURN void error(osmium::io::file_compression compression) {
std::string error_message {"Support for compression '"};
error_message += as_string(compression);
error_message += "' not compiled into this binary.";
Expand Down
6 changes: 5 additions & 1 deletion include/osmium/util/compatibility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ DEALINGS IN THE SOFTWARE.
*/

// Workaround for MSVC which doesn't support constexpr in all cases yet
// Workarounds for MSVC which doesn't support
// * constexpr in all cases yet
// * [[noreturn]]
#ifdef _MSC_VER
# define OSMIUM_CONSTEXPR
# define OSMIUM_NORETURN __declspec(noreturn)
#else
# define OSMIUM_CONSTEXPR constexpr
# define OSMIUM_NORETURN [[noreturn]]
#endif

#endif // OSMIUM_CONFIG_CONSTEXPR_HPP

0 comments on commit 32b2331

Please sign in to comment.