gpt4 book ai didi

c++ - 警告 : passing argument 1 of . .. 从整数生成指针而不进行强制转换

转载 作者:行者123 更新时间:2023-11-28 06:24:09 26 4
gpt4 key购买 nike

我有一个这样的枚举:

enum PROCESS_TYPE
{
PRI_PROC = 0,
BG_PROC = 64,
INT_PROC = 128,
TI_PROC = 256,
PHANTOM = 512,
BLOCK = 1024,
ZOOMBIE = 2048,
ILLEGAL = 4096
};

我有一个名为 create_process 的函数,其中一个参数是 PROCESS_TYPE 类型,如下所示:

create_process(enum PROCESS_TYPE proc_type, const char *name, ...);

当我以这种方式使用 create_process 函数时:

create_process(BG_PROC, "server" ...);

我遇到错误传递“create_process”的参数 1 从整数生成指针而不进行强制转换。如何解决这个问题?提前谢谢你。

编辑:对于第二个参数,它是一个 const char,但它也报告错误 passing argument 2 of 'create_process' makes pointer from integer without a cast

最佳答案

您必须将函数调用更改为 create_process(BG_PROC, "server"); 而不是 create_process(BG_PROC, "server"...);。对我来说,以下代码工作正常..

 enum PROCESS_TYPE {
PRI_PROC = 0,
BG_PROC = 64,
INT_PROC = 128,
TI_PROC = 256,
PHANTOM = 512,
BLOCK = 1024,
ZOOMBIE = 2048,
ILLEGAL = 4096
};

void create_process(enum PROCESS_TYPE, const char *,...);

int main() {
create_process(BG_PROC, "server");
}

void create_process(enum PROCESS_TYPE proc_type, const char *name,...) {
// ...
}

关于c++ - 警告 : passing argument 1 of . .. 从整数生成指针而不进行强制转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28806601/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com