- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有这段代码:
...
#include <stdlib.h>
...
typedef struct tToken
{
tState state; //stav lexemu
char *data; //hodnota lexemu
int row; //radek lexemu
int column; //sloupec lexemu
}tToken;
tToken token;
...
void *gcMalloc(int dataSize){
...
void *AllocatedData = (void*)malloc(dataSize);
return AllocatedData;
}
...
if(token.data == NULL)
token.data = (char *) gcMalloc( sizeof(char) ); //there is the problem
但是错误
warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
仍然存在...有人可以解释一下为什么吗?以及如何改变它?
最佳答案
我的猜测是,您发布的代码并不能准确地代表您的翻译单元(或多个单元)的真实结构。显然,实际上您的 gcMalloc 函数要么是在您调用它之后定义的,要么是在不同的翻译单元中定义的。
同时,在通话时
token.data = (char *) gcMalloc( sizeof(char) );
gcMalloc
函数是完全未知的(未声明、未定义),这使得编译器假定它返回 int
。因此,会出现有关尝试将 32 位 int
值转换为 char *
类型的 64 位指针的警告。
在尝试调用您的 gcMalloc
函数之前,您必须确保该函数已声明。这就是您的 gcMalloc
声明的样子
void *gcMalloc(int dataSize);
如果您的程序由多个翻译单元组成,此类声明通常放置在头文件中,并包含在需要它们的每个翻译单元的最顶部。
并摆脱 Actor 阵容。您在代码中使用的任何强制转换都不是必需的。看起来您添加这些转换的目的是徒劳地尝试抑制指出代码中严重问题的诊断消息。
关于c - malloc : cast to pointer from integer of different size [-Wint-to-pointer-cast],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26288155/
我很确定我不会是第一个被这个绊倒的人,但我找不到答案。这是作业。 class Tier{} class Fisch extends Tier{} class Vogel extends Tier{}
在接收器开发人员指南中如下: Applications running on the Google Cast receiver device (receiver applications) are a
最近我制作了一个自定义本地 Flask 网站,用于从本地设备转换到连接到我的电视的 RPi4。有一个 GUI它也可以通过 GET 请求控制,这是转换工作的主要方式,实际上是通过 GET 请求将数据从
最近我因为某些原因重置了我的路由器,所以当我尝试将它连接到 chromecast 时,Chromecast 没有在其列表中列出我的 wifi 名称。 之前它工作正常,所以我选择其他并手动输入我的网络名
做这样的 Actor 阵容的好方法是什么? seq { yield (box "key", box "val") } |> Seq.cast 因为这看起来非常难看: seq { yield (box
我继承的遗留 Web 应用程序是在经典 ASP 中为新西兰乐施会定制编写的,它在用户提交的输入上运行字符串替换,删除字符串“cast”,大概是因为 cast 函数。 然而,这意味着我们的参与者都不能拥
我去了三星网站并下载了 Media Control SDK 包。当我在我的 Galaxy S3 Android 4.3 上使用 AllShare Cast 视频播放器时,我的智能电视(在同一网络中)出
如何在 BigQuery 中查看 INT64 的二进制表示形式?将其转换为 BYTES 类型也可以。 最佳答案 正如@Elliot Brossard 所述,INT64 如何执行是一个实现问题。类型表示
Google 的文档要求我们设置自己的网络服务器来托管 receiver.html。 是否有任何人都可以使用的默认公共(public) chrome-cast 接收器? 我只需要非常基本的接收器,与
我在 Eclipse 3.6 (Helios) 中运行某人的代码时遇到问题。代码是用 OpenJDK 7 编写的。我运行的是 Windows 7,我必须为它安装 Java 7。我之前使用的是 Java
所以我有一些 COM 类型,它们的名称很难记住、又长又笨重,所以如果可以避免的话,我宁愿在从对象进行转换时不必键入它们。使用 Seq.cast 它将推断所需的类型并根据需要进行强制转换。 这是一个用
假设您不关心编译器和机器的转换风格,以下之间是否存在明显差异: #include #include #include static int64_t tosigned (void *p) {
我的测试类 XString 有两个转换运算符。但是编译器不会为 fooA 使用显式转换 operator const wchar_t*()。为什么? class XString { public:
我有以下代码: T imageCollectionItem; // This checks if image actually exists, if it doesn't it gets the ne
这有点假设,因为我不太担心性能 - 只是想知道一般来说哪个选项实际上最快/最有效,或者是否没有任何区别。 假设我有以下支持重载的访问者模板代码: #define IMPLEMENT_VISITOR_W
我目前正在存储复选框的真/假状态。在注册表中检查值以在下次加载表单时重置。 加载表单时,我获取值并像这样设置复选框。 string value = (string)Registry.GetValue(
enum Gender { Male, Female } var k = new[] { Gender.Male }.Cast().ToList().Cast().ToList(); //alrigh
我正在按照 https://codelabs.developers.google.com/codelabs/cast-receiver#0 上的教程构建一个 chrome cast 自定义接收器。我无
我看不懂以下作品 SELECT price, CAST(price AS DECIMAL(10,2)) FROM orders; 但是更新失败: UPDATE orders SET price = C
在 Cast v3 中,如何手动更改“停止转换”按钮的颜色? 我可以为其他所有内容更改转换对话框或媒体路由器的样式,但“停止转换”按钮似乎会根据背景颜色切换为黑色/蓝色。 我的主题:
我是一名优秀的程序员,十分优秀!