所以我写了一个程序来测试64位kubuntu linux上的线程,版本13.04.实际上我从正在编写测试程序的其他人那里抢了代码.
#include <cstdlib>
#include <iostream>
#include <thread>
void task1(const std::string msg)
{
std::cout << "task1 says: " << msg << std::endl;
}
int main(int argc, char **argv)
{
std::thread t1(task1, "Hello");
t1.join();
return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)
我编译使用:
g++ -pthread -std=c++11 -c main.cpp
g++ main.o -o main.out
Run Code Online (Sandbox Code Playgroud)
然后跑了:
./main.out
Run Code Online (Sandbox Code Playgroud)
顺便说一下,当我使用-l'时,main.out会像所有可执行文件一样以绿色文本显示,但在其名称的末尾也有一个星号.为什么是这样?
回到手头的问题:当我运行main.out时,出现了一个错误,其中说:
terminate called after throwing an instance of 'std::system_error'
what(): Operation not permitted
Aborted (core dumped)
Run Code Online (Sandbox Code Playgroud)
任何有关如何解决此问题的想法?
我在我的WAMP服务器上安装了两个PHP版本.当我使用5.3.10时,我的wamp服务器运行正常.但是当我切换到旧版本的PHP(5.2.9)时,我的wamp服务器托盘图标显示橙色图标.如果你点击Put Online我会收到以下错误.
我试图将httpd.conf中的端口更改为8855,但我仍然遇到同样的错误.我该如何解决这个错误?
无法执行菜单项(内部错误)[例外]无法执行服务操作:服务尚未启动


C++ 11引入了<system_error>包含通用系统的头文件来处理错误代码.An std::error_code是一个元组,包含一个int错误代码和一个对a的引用std::error_category,它定义了错误域和错误代码的处理.标准库带有四个类别:std::generic_category,std::system_category,std::future_category,和std::iostream_category.
有冲突,在其上使用的类别,都在这里SO和C++的参考点,创建时std::error_codeS /投掷std::system_error以s errno和WinAPI的错误代码:
errnowith std::generic_category:SO answer,llvm-commits,cplusplus.comerrnowith std::system_category:SO answer,cppreference.comGetLastError()用std::generic_category:SO回答GetLastError()with std::system_category:SO回答,SO评论但是,errno并且GetLastError()不能使用相同的类别,否则一些错误代码将是不明确的.错误代码33是一个例子,因为它是EDOM和ERROR_LOCK_VIOLATION.
甚至有些地方主张WinAPI的用户制作类别,但我目前找不到任何引用.这种替代方案会特别痛苦.
哪些类别应与使用errno,并应搭配使用GetLastError(),使
std::error_code::default_error_condition()std::error_code::message()是否简单且适用于底层错误代码?
我正在尝试使用该system_error工具来处理我的库中的错误.我将简要讨论库的结构,以防您发现它有用:调用库的命名空间,commons在此我有另一个名为的命名空间dynlib.dynlib包含负责加载.so/.dll文件的类:
namespace commons {
namespace dynlib {
class DynLibLoader {
};
}
}
Run Code Online (Sandbox Code Playgroud)
在DynLibLoader中可能出现的错误LibraryFailedToLoad,LibraryFailedToUnload和SymbolNotFound.所以我对处理错误的想法如下:我将在命名空间error下添加一个命名空间dynlib.然后,在该命名空间下,我将为其定义一个枚举std::error_codes和一个枚举std::error_conditions.从我的理解std::error_codes有对应的值errno(Linux)或GetLastError(Win32的),以及std::error_conditions以价值观一样LibraryFailedToLoad,SymbolNotFound等等.所以,这里是我的问题:
std::error_code和std::error_condition正确吗?errno并GetLastError()在我的std::error_codes枚举下定义它们?如果Microsoft将来向API添加额外的错误值会怎样?我是否必须回到源代码并在我拥有的enum下定义它们std::error_codes?std::error_codes整个公共空间和只定义不同的std::error_condition像每个子命名空间dynlib.这是一个好习惯吗?我会说是的,因为这样可以避免重复的代码.但是这背后有一个问题吗?std::error_category为每个子公共名称空间使用单个.这是一个好习惯吗?你觉得我应该用std::error_category不同的方式吗?我用 AppleScript 制作了一个名为 FRIDAY 的应用程序。当我告诉它“打开 chrome”时,它会打开谷歌浏览器,这是在脚本编辑器和脚本编辑器的外部工作。我还可以告诉它“打开一个新标签”并使用按键打开一个新标签:
-- this boolean is the reason this script keeps runing
set condition to false
say "Welcome sir"
set commands to {"what is todays date", "what time is it", "what is the time", "what day is it", "what month is it", "which month is it", "friday you up", "friday", "friday you tere", "you there", "empty the trash", "take out the trash", "clean up", "new tab", "next tab", "back", "take a nap", "go to sleep", "take …Run Code Online (Sandbox Code Playgroud) applescript keystroke systemevent applescript-objc system-error
我是新来的休息网络服务.
从http://www.mkyong.com/webservices/jax-rs/jersey-hello-world-example/中选取示例
在点击URL时, http://localhost:8080/RESTfulExample/rest/hello/mkyong 我收到了这个奇怪的错误:

细节是:
PLATFORM VERSION INFO
Windows : 6.1.7601.65536 (Win32NT)
Common Language Runtime : 4.0.30319.1022
System.Deployment.dll : 4.0.30319.1 (RTMRel.030319-0100)
clr.dll : 4.0.30319.1022 (RTMGDR.030319-1000)
dfdll.dll : 4.0.30319.1 (RTMRel.030319-0100)
dfshim.dll : 4.0.31106.0 (Main.031106-0000)
SOURCES
Deployment url : http://localhost:8080/rs1/rest/hello/hi,
ERROR SUMMARY
Below is a summary of the errors, details of these errors are listed later in the log.
* Activation of http://localhost:8080/rs1/rest/hello/hi, resulted in exception. Following failure messages were detected:
+ Exception reading manifest from http://localhost:8080/rs1/rest/hello/hi,: the manifest …Run Code Online (Sandbox Code Playgroud) 我有这个简单的代码:
#include <iostream>
#include <fstream>
#include <system_error>
int main(int argc, char *argv[]) {
std::ifstream file;
file.exceptions(std::ios::failbit | std::ios::badbit);
try {
file.open("a_file_does_not_exist.txt", std::ios::in);
file.close();
} catch(const std::ios_base::failure& err) {
std::cerr << err.code() << std::endl;
return -1;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
刚刚完成,这是编译命令:
g++ -std=c++11 -g // ...
Run Code Online (Sandbox Code Playgroud)
编译器的版本是g ++(GCC)6.1.1.
平台:arch-linux 4.7.2-1.
可以想象,该文件不存在,因此该方法file.open(...)将引发异常.问题是,当我运行代码的异常没有被处理,而std::terminate被调用.
奇怪的是输出:
terminate called after throwing an instance of 'std::ios_base::failure'
what(): basic_ios::clear
Annullato (core dump creato)
Run Code Online (Sandbox Code Playgroud)
正如你所读到的那样,投掷课是一个std::ios_base::failure,但我的抓住是正确的. …
我使用从继承的类std::system_error进行错误处理,我想控制what()调用时返回的内容.原因:标准(C++ 11和草案C++ 1y CD - N3690,下面的§引用都是后者)没有说明返回的字符串究竟是what()什么样子,它只是在§19.5中给出了注释.6.2(14):
注意:返回的NTBS可能是内容
what_arg + ": " + code.message(). - 结束说明
所以它应被视为依赖于实现.(顺便说一句,不应该code().message()而不是code.message()?)
所以,问题是:what()如果我想要符合标准并且不依赖于实现(即想要是可移植的),我如何准确定义返回的字符串?
对于那些喜欢代码的人:
class my_class : public std::system_error {
public:
my_class(std::error_code ec, std::string const & what_arg)
: system_error(ec, /* this string is not required to be equal to what is returned by what() */)
{
// ok, try it here
// but what is the name of the member storing the string? …Run Code Online (Sandbox Code Playgroud) 我其目的是使用名为类的系统上工作error_code,error_condition以及error_category-一个方案新标准:在C++ 11,本书虽然此刻我实际使用的加速实现.我已经阅读了Chris Kholkoff的一系列文章,现在已经三次了,我想我一般都懂得如何创建这些类.
我的问题是这个系统需要处理存在于各个DLL中的插件,插件可能会发出错误.我的原始设计是计划一个特定于系统的错误类别,该类别包含所有各种错误代码以及未真正映射到errno值的特定错误条件的列表.这里的问题是,为了使DLL能够使用这些错误代码之一,它需要访问error_category应用程序中的唯一实例.我现在通过SetErrorCategory()从每个DLL 导出一个函数来处理这个问题,这个函数有点工作但是有点icky.
我看到的替代解决方案是每个DLL都有自己的错误类别和代码,如果需要,还有自己的条件; 我怀疑这更像是为这个库功能所设想的.但是,我认为这需要主应用程序的错误方案中的比较函数,该错误方案知道插件的错误方案,并且可以检查应用程序的哪些条件与插件的错误相匹配.这似乎更容易出现一堆问题,尽管我还没有尝试过实现它.我猜我必须在所有实际逻辑之上从DLL导出整个错误方案.
当然,另一种方法是使用DLL中的数字错误代码并将它们填充到应用程序端的错误对象中.它具有插件简单的优点,但可能导致应用程序陷入困境(例如,从几个不同插件中处理对象的函数需要注意每个错误的来源).
所以我的具体问题是:你会使用哪三个选项,为什么?哪个显然不可行?当然,有没有一种更好的方式没有发生在我身上?
倾倒大矩阵(170000*20000)如下
cPickle.dump(train_set,gzip.open('train.pickle.gz','wb'), cPickle.HIGHEST_PROTOCOL)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
SystemError: error return without exception set
Run Code Online (Sandbox Code Playgroud)
在这种情况下我该如何处理?
system-error ×10
c++ ×6
c++11 ×6
applescript ×1
boost ×1
c++14 ×1
error-code ×1
gzip ×1
java ×1
keystroke ×1
php ×1
pickle ×1
posix ×1
rest ×1
systemevent ×1
ubuntu ×1
wampserver ×1
web-services ×1
winapi ×1