为什么要使用 clang 和 gcc,当您想要使用“int32_t”或“memcpy”时,您的包含是不同的

Why use clang and gcc, your include is different when you want use `int32_t` or `memcpy`?

本文关键字:是不同 memcpy 包含 clang gcc int32 为什么      更新时间:2023-10-16

为什么当你想使用int32_tmemcpy时,gcc48和clang之间有不同的包含?

使用

GCC 时,在包含 <iostream> 之后,还应包含用于使用 int32tmemcopy<stdint.h><string.h>

使用clang时,你只需要包含<iostream>,就可以免费使用int32tmemcopy,stdint.h和string.h自动包含。

为什么?我可以运行 clang 作为 gcc 行为吗?

我使用Mac OS。

可能是因为 clang 的标准库恰好包含 <stdint.h><string.h> 已经出于自己的私人原因<iostream>; 这是不能保证的,而且,正如你所看到的,你的gcc的标准库不是这样工作的。

不要依赖这种行为;无论这些巧合如何,始终包含所需的文件。

相关文章: