cstdlib 无法通过 ::wcstombs 解析

3

我将我的系统升级到了Fedora 33之后,发现stdlib.h无法解析一些数据结构:

In file included from /usr/include/c++/10/cstdlib:75,
                 from /usr/include/c++/10/ext/string_conversions.h:41,
                 from /usr/include/c++/10/bits/basic_string.h:6545,
                 from /usr/include/c++/10/string:55,
                 from /home/ideepika/ceph5/ceph/src/rocksdb/include/rocksdb/cache.h:27,
                 from /home/ideepika/ceph5/ceph/src/rocksdb/cache/clock_cache.h:12,
                 from /home/ideepika/ceph5/ceph/src/rocksdb/cache/clock_cache.cc:10:
/usr/include/stdlib.h:935:5: error: expected initializer before ‘__attr_access’
  935 |     __attr_access ((__read_only__, 2));
      |     ^~~~~~~~~~~~~
/usr/include/stdlib.h:940:3: error: expected initializer before ‘__attr_access’
  940 |   __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
      |   ^~~~~~~~~~~~~
/usr/include/stdlib.h:994:30: error: expected initializer before ‘__attr_access’
  994 |      __THROW __nonnull ((2)) __attr_access ((__write_only__, 2, 3));
      |                              ^~~~~~~~~~~~~
In file included from /usr/include/c++/10/ext/string_conversions.h:41,
                 from /usr/include/c++/10/bits/basic_string.h:6545,
                 from /usr/include/c++/10/string:55,
                 from /home/ideepika/ceph5/ceph/src/rocksdb/include/rocksdb/cache.h:27,
                 from /home/ideepika/ceph5/ceph/src/rocksdb/cache/clock_cache.h:12,
                 from /home/ideepika/ceph5/ceph/src/rocksdb/cache/clock_cache.cc:10:
/usr/include/c++/10/cstdlib:154:11: error: ‘mbstowcs’ has not been declared in ‘::’
  154 |   using ::mbstowcs;
      |           ^~~~~~~~
/usr/include/c++/10/cstdlib:171:11: error: ‘wcstombs’ has not been declared in ‘::’
  171 |   using ::wcstombs;
      |           ^~~~~~~~

错误的源头仅仅是因为#include,因此来自rocksdb的源代码看起来并不可疑。

正在调查中...将会用相关细节更新,如果需要添加更多细节,请告诉我。


1
很奇怪,在我的F33上完全没有这样的问题。<cstdlib>可以正常地被包含。错误表明正在构建某个大型软件包。它可能在做一些不太规范的事情,并且被新编译器绊倒了。闻起来像是“using namespace std”。 - Sam Varshavchik
我不确定,但看起来你的libc++与libc不兼容。 - eerorika
无关:我推迟了我的F33升级 :-) - Ted Lyngmo
@TedLyngmo 我认为Sam可能是正确的,我和同事核实过,他们在f33上没有遇到任何问题... - Deepika Upadhyay
@DeepikaUpadhyay 很高兴听到这个好消息。我下载了ceph5及其所有子模块,并快速查看了一下看是否能找到罪魁祸首,但是时间有限 : )。我在一个子模块的C++头文件中看到了一个stdlib.hstdint.h的引入,但那可能不是原因。 - Ted Lyngmo
1
@TedLyngmo 谢谢你的帮忙!我解决了那些问题,分号就是它了!! - Deepika Upadhyay
1个回答

2
原来在 cstdlib 中最近添加了一个补丁:https://www.cygwin.com/bugzilla/attachment.cgi?id=12133。可能之前没有被发现,我现在还没有调查相关文件,但如果其他人遇到了这个问题,可以添加这个最小更改的补丁集解决。
diff --git a/stdlib.h b/stdlib.h
index f255e4a..d88ef89 100644
--- a/stdlib.h
+++ b/stdlib.h
@@ -931,10 +931,11 @@ extern int wctomb (char *__s, wchar_t __wchar) __THROW;
 
 /* Convert a multibyte string to a wide char string.  */
 extern size_t mbstowcs (wchar_t *__restrict  __pwcs,
-                       const char *__restrict __s, size_t __n) __THROW
+                       const char *__restrict __s, size_t __n) __THROW;
 /* Convert a wide char string to multibyte string.  */
 extern size_t wcstombs (char *__restrict __s,
-                       const wchar_t *__restrict __pwcs, size_t __n) __THROW
+                       const wchar_t *__restrict __pwcs, size_t __n)
+     __THROW;
 
 #ifdef __USE_MISC
 /* Determine whether the string value of RESPONSE matches the affirmation
@@ -988,7 +989,7 @@ extern char *ptsname (int __fd) __THROW __wur;
    terminal associated with the master FD is open on in BUF.
    Return 0 on success, otherwise an error number.  */
 extern int ptsname_r (int __fd, char *__buf, size_t __buflen)
-     __THROW __nonnull ((2))
+     __THROW __nonnull ((2));

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接