Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds workaround to compile the project with clang -Wall -Werror #310

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/amqpcpp/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ class Array : public Field
stream << ")";
}

#ifndef AMQPCPP_NO_IMPLICIT_CAST
/**
* Cast to array.
*
Expand All @@ -230,13 +231,16 @@ class Array : public Field
* Yes, clang gets this wrong and gives incorrect warnings here. See
* https://llvm.org/bugs/show_bug.cgi?id=28263 for more information
*
* If you still want to avoid this warning but lose the functionality define AMQPCPP_NO_IMPLICIT_CAST before including amqpcpp.h
*
* @return Ourselves
*/
virtual operator const Array& () const override
{
// this already is an array, so no cast is necessary
return *this;
}
#endif
};

/**
Expand Down
2 changes: 2 additions & 0 deletions include/amqpcpp/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ class Field
virtual operator int64_t () const { return 0; }
virtual operator float () const { return 0; }
virtual operator double () const { return 0; }
#ifndef AMQPCPP_NO_IMPLICIT_CAST
virtual operator const Array& () const;
virtual operator const Table& () const;
#endif

/**
* Check the field type
Expand Down
4 changes: 4 additions & 0 deletions include/amqpcpp/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ class Table : public Field
stream << ")";
}

#ifndef AMQPCPP_NO_IMPLICIT_CAST
/**
* Cast to table.
*
Expand All @@ -264,13 +265,16 @@ class Table : public Field
* Yes, clang gets this wrong and gives incorrect warnings here. See
* https://llvm.org/bugs/show_bug.cgi?id=28263 for more information
*
* If you still want to avoid this warning but lose the functionality define AMQPCPP_NO_IMPLICIT_CAST before including amqpcpp.h
*
* @return Ourselves
*/
virtual operator const Table& () const override
{
// this already is a table, so no cast is necessary
return *this;
}
#endif
};

/**
Expand Down
2 changes: 2 additions & 0 deletions src/field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Field::operator const std::string& () const
return empty;
}

#ifndef AMQPCPP_NO_IMPLICIT_CAST
/**
* Cast to array
* @return Array
Expand All @@ -83,6 +84,7 @@ Field::operator const Table& () const
// return it
return empty;
}
#endif

/**
* End of namespace
Expand Down