GCC:从4.9更新到8.x会导致错误:' min'在此范围内没有宣布

发布于 2025-02-10 09:46:37 字数 329 浏览 0 评论 0原文

我从Debian Jessie更新到Buster,现在在Linux中构建了共享的代码库(跨Windows,Linux等共享)构建(库已有20年的历史,为什么要破坏它)。

它正在构建的模块是.cpp,是否有一个开关以使其像以前一样使用min()。我宁愿不要将宏插入主头部,因为它会触发所有其他平台的重建,并且图书馆非常大。由于其他环境可能会使用较旧的编译器,因此我无法强迫它使用STD:最小值。

更多信息:

如果我包括以下内容,这似乎正在发生:

#include< stdlib.h>

tia!

I updated from Debian Jessie to Buster and now the shared code libraries (shared across Windows, Linux, etc..) build are broken in Linux (the library is over 20 years old, why break it).

The module it was building was .cpp, is there a switch to get it to use min() as it was before. I'd rather not put a macro in the main header as it triggers a rebuild across all other platforms and the library is very large. No way can I force it to use std:min because other environments may use older compilers.

MORE INFORMATION:

This seems to be occurring if I include the following:

#include <stdlib.h>

TIA!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我还不会笑 2025-02-17 09:46:37

新的stdlib.h将不确定min()/max(),因此我在gccfix的早期中包括stdlib.h来解决它。我已经有了标题。在该标头中,我已经定义了min()/max()(如果丢失)。

#if defined(__cplusplus)
#include <stdlib.h>
#endif

#ifndef max
#define max(a,b)            (((a) > (b)) ? (a) : (b))
#endif

#ifndef min
#define min(a,b)            (((a) < (b)) ? (a) : (b))
#endif

现在构建正在运行。

The new stdlib.h will undefine min()/max() so I worked around it by including stdlib.hearly in a gccfix up header I already had. In that header I already defined min()/max() if missing.

#if defined(__cplusplus)
#include <stdlib.h>
#endif

#ifndef max
#define max(a,b)            (((a) > (b)) ? (a) : (b))
#endif

#ifndef min
#define min(a,b)            (((a) < (b)) ? (a) : (b))
#endif

Now the build is running.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文