How to make compiler not show int to void pointer cast warnings

Jean-Luc Nacif Coelho

I have some code that does lots of casting from int to void* and vice-versa (i don't care if it's ugly. I like having generic stuff)

Example:

typedef struct _List {
    long size;
    long mSize; // Max size
    void** elementArray;
}List;

List l;
...
int i = 2;
l.elementArray[i] = i; // Intentional usage of pointer as integer
// Actual size of pointer does not matter

but when i compile i get a bajillion

 warning: cast to 'void *' from smaller integer type 'int' [-Wint-to-void-pointer-cast]

warnings. Is there a flag to tell gcc to not print this specific warning?

I'm compiling with -Wall, so I'm not sure if i can make this go away that easilly

Jean-Luc Nacif Coelho

apparently just take the flag that the compiler gives you and slap a "no" in front of it does the trick!

-Wno-int-to-void-pointer-cast

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

How do I cast a 2D list to a void pointer and back

来自分类Dev

Argument conversion: (normal) pointer to void pointer, cast needed?

来自分类Dev

How to cast JSONArray to int array?

来自分类Dev

Why does this function cast an int argument to a volatile pointer and immediately dereferences it?

来自分类Dev

Understanding how the compiler resolves pointer to functions

来自分类Dev

解释static_cast“ static_cast <void(Pet :: *)(int)>”语法吗?

来自分类Dev

存储std :: weak_ptr <void>并使用static_pointer_cast

来自分类Dev

为什么在C ++中不允许将static_cast从int(*)(int)转换为void *?

来自分类Dev

How to cast Int to unsigned short in Swift

来自分类Dev

Cast function to function pointer

来自分类Dev

Bizarre Dart compiler warnings on http lib

来自分类Dev

void(int)和void(*)(int)之间的区别

来自分类Dev

Cast float to int, or int to float?

来自分类Dev

How to reset warnings completely

来自分类Dev

错误:从'int(*)(void *)'到'void *(*)(void *)'的无效转换

来自分类Dev

错误:从'void *'到'int(*)(const void *,const void *)'的无效转换

来自分类Dev

如何将“ void(MyClass :: *)(int)”转换为“ void(*)(int)”?

来自分类Dev

int to char cast,奇怪的行为

来自分类Dev

How to make a log-file of an R-session which combines commands, results and warnings/messages/errors from the R-console

来自分类Dev

从不兼容的void分配int *

来自分类Dev

从void指针获取int的问题

来自分类Dev

将int转换为void *

来自分类Dev

从void指针获取int的问题

来自分类Dev

克隆void *指向int的指针

来自分类Dev

static_cast int 引用int?

来自分类Dev

Should a void* pointer passed in by a callback be deleted

来自分类Dev

(void *)指针和&pointer之间的区别?

来自分类Dev

Why is it a pointer to void declarator instead of a pointer to member function?

来自分类Dev

How to make objdump show assembly of sections only appeared in source code?

Related 相关文章

  1. 1

    How do I cast a 2D list to a void pointer and back

  2. 2

    Argument conversion: (normal) pointer to void pointer, cast needed?

  3. 3

    How to cast JSONArray to int array?

  4. 4

    Why does this function cast an int argument to a volatile pointer and immediately dereferences it?

  5. 5

    Understanding how the compiler resolves pointer to functions

  6. 6

    解释static_cast“ static_cast <void(Pet :: *)(int)>”语法吗?

  7. 7

    存储std :: weak_ptr <void>并使用static_pointer_cast

  8. 8

    为什么在C ++中不允许将static_cast从int(*)(int)转换为void *?

  9. 9

    How to cast Int to unsigned short in Swift

  10. 10

    Cast function to function pointer

  11. 11

    Bizarre Dart compiler warnings on http lib

  12. 12

    void(int)和void(*)(int)之间的区别

  13. 13

    Cast float to int, or int to float?

  14. 14

    How to reset warnings completely

  15. 15

    错误:从'int(*)(void *)'到'void *(*)(void *)'的无效转换

  16. 16

    错误:从'void *'到'int(*)(const void *,const void *)'的无效转换

  17. 17

    如何将“ void(MyClass :: *)(int)”转换为“ void(*)(int)”?

  18. 18

    int to char cast,奇怪的行为

  19. 19

    How to make a log-file of an R-session which combines commands, results and warnings/messages/errors from the R-console

  20. 20

    从不兼容的void分配int *

  21. 21

    从void指针获取int的问题

  22. 22

    将int转换为void *

  23. 23

    从void指针获取int的问题

  24. 24

    克隆void *指向int的指针

  25. 25

    static_cast int 引用int?

  26. 26

    Should a void* pointer passed in by a callback be deleted

  27. 27

    (void *)指针和&pointer之间的区别?

  28. 28

    Why is it a pointer to void declarator instead of a pointer to member function?

  29. 29

    How to make objdump show assembly of sections only appeared in source code?

热门标签

归档