Browse Source

doc: finally fix all those annoying warnings in code snippets.

pull/525/head
Vladimír Vondruš 4 years ago
parent
commit
319b112f4b
  1. 21
      doc/snippets/MagnumAnimation.cpp
  2. 8
      doc/snippets/MagnumMath.cpp
  3. 11
      doc/snippets/MagnumPlatform.cpp
  4. 38
      doc/snippets/MagnumSceneGraph.cpp

21
doc/snippets/MagnumAnimation.cpp

@ -33,6 +33,8 @@
#include "Magnum/Animation/Easing.h"
#include "Magnum/Animation/Player.h"
#define DOXYGEN_ELLIPSIS(...) __VA_ARGS__
using namespace Magnum;
using namespace Magnum::Math::Literals;
@ -55,7 +57,7 @@ static_cast<void>(result2);
{
/* [unpack] */
UnsignedShort a, b;
UnsignedShort a = DOXYGEN_ELLIPSIS(0), b = DOXYGEN_ELLIPSIS(0);
auto lerpPacked =
Animation::unpack<UnsignedShort, Float, Math::lerp, Math::unpack<Float>>();
@ -68,7 +70,7 @@ static_cast<void>(result2);
{
/* [unpackEase] */
UnsignedShort a, b;
UnsignedShort a = DOXYGEN_ELLIPSIS(0), b = DOXYGEN_ELLIPSIS(0);
auto lerpPackedBounceIn = Animation::unpackEase<UnsignedShort, Float,
Math::lerp, Math::unpack<Float>, Animation::Easing::bounceIn>();
@ -150,8 +152,6 @@ player.add(scaling, objectScaling)
/* [Player-usage] */
}
/* WinRT has warnings-as-errors and fails on the unitialized object var */
#ifndef CORRADE_TARGET_WINDOWS_RT
{
const Animation::TrackView<Float, Vector3> translation;
const Animation::TrackView<Float, Quaternion> rotation;
@ -161,15 +161,8 @@ struct Object3D {
Object3D& setRotation(const Quaternion&) { return *this; }
Object3D& setScaling(const Vector3&) { return *this; }
};
#ifdef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
/* [Player-usage-callback] */
Object3D* object;
Object3D* object = DOXYGEN_ELLIPSIS({});
Animation::Player<Float> player;
player.addWithCallback(scaling,
@ -185,11 +178,7 @@ player.addWithCallback(translation,
object.setTranslation(translation);
}, *object);
/* [Player-usage-callback] */
#if defined(__clang__) || defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
}
#endif
{
/* [Player-usage-playback] */

8
doc/snippets/MagnumMath.cpp

@ -627,7 +627,7 @@ static_cast<void>(radians);
}
{
#if defined(CORRADE_TARGET_GCC) && __GNUC__ >= 11
#if (defined(CORRADE_TARGET_GCC) && __GNUC__ >= 11) || defined(CORRADE_TARGET_CLANG)
#pragma GCC diagnostic push
/* Stupid thing. YES I WANT THIS TO BE A FUNCTION, CAN YOU SHUT UP */
#pragma GCC diagnostic ignored "-Wvexing-parse"
@ -641,7 +641,7 @@ Radd radians{foo()};
/* [Deg-usage-convert] */
static_cast<void>(degrees);
static_cast<void>(radians);
#if defined(CORRADE_TARGET_GCC) && __GNUC__ >= 11
#if (defined(CORRADE_TARGET_GCC) && __GNUC__ >= 11) || defined(CORRADE_TARGET_CLANG)
#pragma GCC diagnostic pop
#endif
}
@ -656,7 +656,7 @@ static_cast<void>(b);
}
{
#if defined(CORRADE_TARGET_GCC) && __GNUC__ >= 11
#if (defined(CORRADE_TARGET_GCC) && __GNUC__ >= 11) || defined(CORRADE_TARGET_CLANG)
#pragma GCC diagnostic push
/* Stupid thing. YES I WANT THIS TO BE A FUNCTION, CAN YOU SHUT UP */
#pragma GCC diagnostic ignored "-Wvexing-parse"
@ -669,7 +669,7 @@ Deg x = angle(); // convert to degrees for easier comparison
if(x < 30.0_degf) foo();
//if(x > 1.57_radf) bar(); // error, both need to be of the same type
/* [Deg-usage-comparison] */
#if defined(CORRADE_TARGET_GCC) && __GNUC__ >= 11
#if (defined(CORRADE_TARGET_GCC) && __GNUC__ >= 11) || defined(CORRADE_TARGET_CLANG)
#pragma GCC diagnostic pop
#endif
}

11
doc/snippets/MagnumPlatform.cpp

@ -23,6 +23,8 @@
DEALINGS IN THE SOFTWARE.
*/
#define DOXYGEN_ELLIPSIS(...) __VA_ARGS__
/* [windowed] */
#include <Magnum/GL/DefaultFramebuffer.h>
#include <Magnum/GL/Renderer.h>
@ -182,14 +184,10 @@ void MyApplication::globalDrawEvent() {
void foo();
void foo() {
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
/* [ScreenedApplication-for-range] */
MyApplication app;
for(Platform::Screen& screen: app.screens()) {
// ...
DOXYGEN_ELLIPSIS(static_cast<void>(screen));
}
/* [ScreenedApplication-for-range] */
@ -198,9 +196,6 @@ for(Platform::Screen* s = app.screens().first(); s; s = s->nextFartherScreen())
// ...
}
/* [ScreenedApplication-for] */
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
}
}

38
doc/snippets/MagnumSceneGraph.cpp

@ -38,6 +38,8 @@
#include "Magnum/SceneGraph/Object.h"
#include "Magnum/SceneGraph/Scene.h"
#define DOXYGEN_ELLIPSIS(...) __VA_ARGS__
using namespace Magnum;
using namespace Magnum::Math::Literals;
@ -63,6 +65,11 @@ class TransformingFeature: public SceneGraph::AbstractFeature3D {
template<class T> explicit TransformingFeature(SceneGraph::Object<T>& object):
SceneGraph::AbstractFeature3D{object}, _transformation{object} {}
DOXYGEN_ELLIPSIS(void foo() {
/* to avoid warnings about an unused private field */
_transformation.translate({});
})
private:
SceneGraph::AbstractTranslationRotation3D& _transformation;
};
@ -138,23 +145,21 @@ class CachingObject: public Object3D, SceneGraph::AbstractFeature3D {
namespace {
#ifdef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-private-field"
#endif
/* [transformation] */
class TransformingFeature: public SceneGraph::AbstractFeature3D {
public:
template<class T> explicit TransformingFeature(SceneGraph::Object<T>& object):
SceneGraph::AbstractFeature3D(object), _transformation(object) {}
DOXYGEN_ELLIPSIS(void foo() {
/* to avoid warnings about an unused private field */
_transformation.translate({});
})
private:
SceneGraph::AbstractTranslationRotation3D& _transformation;
};
/* [transformation] */
#ifdef __clang__
#pragma GCC diagnostic pop
#endif
}
@ -271,13 +276,9 @@ class MyObject: MyFeature, public Object3D {
{
SceneGraph::Object<SceneGraph::MatrixTransformation3D> object;
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
/* [AbstractObject-features-range] */
for(SceneGraph::AbstractFeature3D& feature: object.features()) {
// ...
DOXYGEN_ELLIPSIS(static_cast<void>(feature));
}
/* [AbstractObject-features-range] */
@ -285,17 +286,14 @@ for(SceneGraph::AbstractFeature3D& feature: object.features()) {
/* [Object-children-range] */
Object3D o;
for(Object3D& child: o.children()) {
// ...
DOXYGEN_ELLIPSIS(static_cast<void>(child));
}
/* [Object-children-range] */
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
/* [AbstractObject-features] */
for(SceneGraph::AbstractFeature3D* feature = object.features().first(); feature; feature = feature->nextFeature()) {
// ...
DOXYGEN_ELLIPSIS()
}
/* [AbstractObject-features] */
@ -303,7 +301,7 @@ for(SceneGraph::AbstractFeature3D* feature = object.features().first(); feature;
Object3D o;
/* [Object-children] */
for(Object3D* child = o.children().first(); child; child = child->nextSibling()) {
// ...
DOXYGEN_ELLIPSIS()
}
/* [Object-children] */
}
@ -315,7 +313,7 @@ SceneGraph::AnimableGroup3D animables;
(new AnimableObject(&scene, &animables))
->setState(SceneGraph::AnimationState::Running);
// ...
DOXYGEN_ELLIPSIS()
/* [Animable-usage] */
}
@ -365,7 +363,7 @@ SceneGraph::DrawableGroup3D drawableGroup;
struct CullableDrawable3D: SceneGraph::Drawable3D {
Range3D aabb; /* Relative to world origin */
// ...
DOXYGEN_ELLIPSIS()
};
/* Camera frustum relative to world origin */

Loading…
Cancel
Save