- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 android ndk 将 Box2D 编译为适用于 android 的 64 位版本
但是我遇到了很多这样的错误:
andEnginePhysicsBox2DExtension/src/main/jni\Box2D/Collision/Shapes/b2ChainShape.h:111:20: warning: implicit conversion of NULL constant to 'bool' [-Wnull-conversion] m_hasPrevVertex = NULL; ~ ^~~~ false
这就是我的 b2ChainShape.h 的内容
/*
* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef B2_CHAIN_SHAPE_H
#define B2_CHAIN_SHAPE_H
#include <Box2D/Collision/Shapes/b2Shape.h>
class b2EdgeShape;
/// A chain shape is a free form sequence of line segments.
/// The chain has two-sided collision, so you can use inside and outside collision.
/// Therefore, you may use any winding order.
/// Since there may be many vertices, they are allocated using b2Alloc.
/// Connectivity information is used to create smooth collisions.
/// WARNING: The chain will not collide properly if there are self-intersections.
class b2ChainShape : public b2Shape
{
public:
b2ChainShape();
/// The destructor frees the vertices using b2Free.
~b2ChainShape();
/// Create a loop. This automatically adjusts connectivity.
/// @param vertices an array of vertices, these are copied
/// @param count the vertex count
void CreateLoop(const b2Vec2* vertices, int32 count);
/// Create a chain with isolated end vertices.
/// @param vertices an array of vertices, these are copied
/// @param count the vertex count
void CreateChain(const b2Vec2* vertices, int32 count);
/// Establish connectivity to a vertex that precedes the first vertex.
/// Don't call this for loops.
void SetPrevVertex(const b2Vec2& prevVertex);
/// Establish connectivity to a vertex that follows the last vertex.
/// Don't call this for loops.
void SetNextVertex(const b2Vec2& nextVertex);
/// Implement b2Shape. Vertices are cloned using b2Alloc.
b2Shape* Clone(b2BlockAllocator* allocator) const;
/// @see b2Shape::GetChildCount
int32 GetChildCount() const;
/// Get a child edge.
void GetChildEdge(b2EdgeShape* edge, int32 index) const;
/// This always return false.
/// @see b2Shape::TestPoint
bool TestPoint(const b2Transform& transform, const b2Vec2& p) const;
/// Implement b2Shape.
bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
const b2Transform& transform, int32 childIndex) const;
/// @see b2Shape::ComputeAABB
void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const;
/// Chains have zero mass.
/// @see b2Shape::ComputeMass
void ComputeMass(b2MassData* massData, float32 density) const;
/// Get the number of vertices.
int32 GetVertexCount() const { return m_count; }
/// Get the vertices (read-only).
const b2Vec2& GetVertex(int32 index) const
{
b2Assert(0 <= index && index < m_count);
return m_vertices[index];
}
/// Get the vertices (read-only).
const b2Vec2* GetVertices() const { return m_vertices; }
/// The vertices. Owned by this class.
b2Vec2* m_vertices;
/// The vertex count.
int32 m_count;
b2Vec2 m_prevVertex, m_nextVertex;
bool m_hasPrevVertex, m_hasNextVertex;
};
inline b2ChainShape::b2ChainShape()
{
m_type = e_chain;
m_radius = b2_polygonRadius;
m_vertices = NULL;
m_count = 0;
m_hasPrevVertex = NULL;
m_hasNextVertex = NULL;
}
#endif
如有任何建议,我们将不胜感激
最佳答案
你在这里得到的警告
implicit conversion of NULL constant to 'bool' [-Wnull-conversion] m_hasPrevVertex = NULL; ~ ^~~~ false
告诉您,您有 bool
字段,这些字段是用 NULL
而不是实际的 boolean 值初始化的。例如 m_hasPrevVertex
和 m_hasNextVertex
。因此,编译器试图通过将这些值隐式设置为 false
并通知您这一事实来解决此问题。
在这种情况下,这不是严重错误,但绝对是代码味道。 (虽然,也许不同的编译器实际上会在这里抛出错误,我不确定)
您可以通过简单地将所有 boolean 值初始化为 true
或 false
来消除这些警告,具体取决于您的用例。
关于java - BOX2D - 将 NULL 常量隐式转换为 'bool' [-Wnull-conversion],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57843472/
我试图为此搜索答案,但我发现很难找到这种“确切”的例子。我对指向指针的指针知之甚少,我觉得除了指向某物的指针之外,还有更多东西隐藏在它的表层之下。 那么你们会如何翻译呢? void free(sham
我有一个类的属性,比如const CFoo &bar() const,这是什么意思? 最佳答案 bar 方法返回对 const CFoo 的引用(即 bar 之前的 const CFoo & 部分),
例如是 int const x = 3; 有效代码? 如果是的话,意思是一样的 const int x = 3; ? 最佳答案 它们都是有效的代码并且它们都是等价的。对于指针类型,尽管它们都是有效代码
我知道 f(const T& obj) // (1) g(T const& obj) // (2) 是一样的。(我们不能改变f和g中obj的值)。 但是什么 h(T & const) // (3) 真
本节讲解的内容 include和include_once require和require_once 常量 引入文件和常量结合案列 变量操作函数 输出语句 前言 在上篇文章中,我们讨论了函数的应用,但是
我们知道我们可以保护变量的值,因此用户无法更改现有变量的值!这对对象来说没有什么问题吗?? 例如.. const x = 5; x = 10; alert(x) // will be returned
我正准备为 CUDA 设备编写直方图内核。它基于 NVIDIA's paper . 这个想法是每个线程计算某个部分(在我的例子中是体积)的部分直方图并将其写入共享内存块。然而,我遇到了一个奇怪的算法问
常量是固定值,程序执行期间不会改变。常量可以是任何基本数据类型,比如整数常量、浮点常量、字符常量或者字符串常量,还有枚举常量。 常量可以被当作常规的变量,只是它们的值在定义后不能被修改。 整数常
在这种情况下,如何识别是否有变量或字面量传递给函数 f()? 如何实现passed_as_constant()检查(见下面代码)? sub f { my $refStr=\$_[0]; ret
我目前想知道如何在 python 中列出 win32com 中的常量, 例如使用 excel win32com.client.Dispatch('Excel.Application') 有没有办法使用
这个问题在这里已经有了答案: PHP | define() vs. const (9 个回答) 关闭8年前。 在 PHP 中遇到常量问题想知道是否有人可以解释: 这行得通 const _ROOT =
我正在学习 Rust,到目前为止,似乎有 3 种声明变量的方法: const A: u8 = 42; static A: u8 = 42; let A: u8 = 42; 我知道你不能有一个可变的 c
我正在使用函数模板 void _createAttr(T)(args..., in T[]) 并使用 测试 T 的类型函数中的 static if(is(T == char)) 。当我打电话时, _c
这可能是一个天真的问题,我怀疑答案是"is",但我没有运气在这里和其他地方搜索“erlang编译器优化常量”等术语。无论如何,erlang 编译器是否可以(将)在编译时创建一个常量或文字的数据结构,并
我刚遇到这段 Java 脚本代码: const { myKey, uname, issorted, title, hClick, } = this.props; 请告诉我这是什么意
我正在努力实现以下目标: 我有一个父类,有一些逻辑。在子类中,我“重新定义”常量/属性。有没有办法让子属性可以通过父类中定义的方法访问?或者更具体地说 - 有什么方法可以强制“out”方法在下面的示例
如果这是个愚蠢的问题,请原谅。 我有一个带有内部类接口(interface)的“fragment ”外部类。该接口(interface)仅由另一个 Activity 类使用“implements Ou
我是 python 新手,尝试使用默认值并为类实例自定义它们。 因此,在这个示例中,我定义了一个 DEFAULT_STRING 和一个 DEFAULT_SETTINGS 变量,可以使用 customi
在 integer.xml 中,其形式为 0x001 0x002 是代码和 xml 文件都需要的存储常量。 C# 识别 Droid.Resource.Integer.foo,但它有一些大的
是否有跨平台(即跨 Linux、BSD 和 OS X,最好是所有 POSIX)我可以纯粹基于字符串 以编程方式访问诸如 O_RDWR 之类的常量>“O_RDWR”?我正在编写一些(非 C)代码,这些代
我是一名优秀的程序员,十分优秀!