::system has not been declared 的问题

原创 2007年10月05日 16:26:00
这个问题的出现是由于system宏在phtread.h中已经有定义,因而产生了冲突,至于为什么这样会产生冲突,我也没想明白,希望高手指点,谢!
一英文网站上贴出的解释:
In <cstdlib> we have:

[-- <cstdlib> ----------]
...
#include <bits/c++config.h>
#include <cstddef>
#include <stdlib.h>
...
#undef system
...
namespace std {
...
using ::system;
...
}
...
[-- <cstdlib> ----------]

And in <pthreads.h> from (GNU pth) we have:

[-- <pthread.h> --------]
#define system __pthread_system
[-- <pthread.h> --------]

So <bits/c++config.h> is indirectly #including <pthreads.h>, and
that #defines the new function, changes all occurrences from there,
and thus the ones on <stdlib.h>, and then <cstdlib> undefs it, so
when the it tries to reference ::system in the using sentence it
cannot find it because it hase been previously remmaped to
__pthread_system.

A test case to show that this is the problem could be:

[-- test-ok.cc ---------]
#include <pthreads.h>
#undef system
#include <cstdlib>
int main() { return 0; }
[-- test-ok.cc ---------]

I'm not sure what's the proper fix, on <cstdlib> we can read:

// Get rid of those macros defined in <stdlib.h> in lieu of real functions.

There are multiple ways to fix this:

* Move the <stdlib.h> and #undefs before #including <bits/c++config.h>
and <cstddef>, as it's supposedly intended to only get rid of macros
from <stdlib.h>.
* Do no undef those macros on <cstdlib>.
* Do not define those macros in <pthread.h> as they are not defined
for LinuxThreads for example.
上诉方法不见得都可以,大家可以试试
我是感觉这些方法也许会给以后带来隐患,就都没用,我在cstdlib.h文件中的
#include <bits/c++config.h>
#include <cstddef>
下加了一句
#undef system
也可以解决问题,而且应该不会在以后的编程中出现因为这个的改动而出现问题
如果会,也希望高手指点!~  
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

The 3D Analyst extension has not been enabled.

再次遇到这个问题,之前有解决,当时并没有记下来,导致本次处理的时候有点模糊不清。在此做个总结,以此铭记!        这个问题主要原因是权限的问题,因为在AE开发过程中,要取得相应的权限。ArcGI...
  • gwbob
  • gwbob
  • 2015-07-14 09:27
  • 709

kafka异常:Uncaught exception in kafka-producer-network-thread 异常:Kafka scheduler has not been started

版本: kafka_2.11-0.8.2.2 client:java-client 现象: kafka写入数据失败,没有异常信息. kafka客户端生产者日志: 服务器一: 2016...

Code::Blocks之It seems that this file has not been built yet.

这两天在学习Objective-C,在Windows下面通过GNUstep和Code::Blocks的结合来进行代码的编辑和测试。关于GNUstep和Code::Blocks的环境的配置网上有很多教程...

SDK更新后,重新打开Eclipse时提示错误Location of the Android SDK has not been setup in the preferences

SDK更新后,重新打开Eclipse时提示错误Location of the Android SDK has not been setup in the preferences 现象描述       ...
  • fpxty
  • fpxty
  • 2017-05-12 18:00
  • 538

location of the android sdk has not been setup in the preferences

打开eclipse时出现无法识别android的项目,即所有android项目均显示红色错误标记。点击eclipse管理android SDK and AVD Manager 插件的标志时出现错误: ...

Unity发布android错误:Bundle Identifier has not been set up correctly

Re: 發佈出現錯誤 由 zeldein » 2012年 3月 12日, 15:47 sega2009 寫:出現錯誤視窗Bundle Identifier has not been ...

openwrt Signing key has not been configured解决方法

在编译openwrt源码的时候make V=s 提示openwrt出现Signing key has not been configured解决办法 编译出现提示如下: Generating inde...

location of the android sdk has not been setup in the preferences的解决方法

本文转自:http://hi.baidu.com/azhangdeng/blog/item/063b4e90109ec5176e068c8d.html location of the a...

SRVE0255E: A WebGroup/Virtual Host to handle /p2pd/servlet/dispatch has not been defined.

Technote (troubleshooting) Problem(Abstract) When setting up IBM Cognos within IBM WebSphe...

sybase存储设备has not been correctly activated at startup time

昨天又有开发同事表示sybase数据库使用又出现故障,报错情况如下图: (1)客户端无法登陆sybase数据库,报错信息如下: Device 'add_device' (with physical...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)