例如,我的makefile中有类似的东西:
all:
cd some_directory
Run Code Online (Sandbox Code Playgroud)
但是当我输入时,我make只看到'cd some_directory',就像在echo命令中一样.
我有一个std :: map <std :: string,std :: string> cont;
我想在gdb中看到cont ["some_key"].当我在尝试
p cont ["some_ket"]
我收到此消息:您尝试传递给operator []的其中一个参数无法转换为函数所需的内容.
我正在使用GNU gdb Red Hat Linux(6.3.0.0-1.162.el4rh).谢谢
我有一个std :: map <std :: string,std :: string>,它通过一些API调用初始化.当我试图使用这张地图时,我遇到了分段错误.如何检测无效代码或无效代码或任何可以帮助我解决问题的细节?代码如下所示:
std::map< std::string, std::string> cont;
some_func( cont ); // getting parameter by reference and initialize it, someone corrupted memory (cont) inside this function
std::cout << cont[ "some_key" ] << '\n'; // segmentation fault here, cannot access "some_key"
Run Code Online (Sandbox Code Playgroud) 我的gdb是GNU gdb Red Hat Linux(6.3.0.0-1.162.el4rh).我无法调试模板.如何使用此调试器调试模板?
我想实现is_pointer.我想要这样的东西:
template <typename T >
bool is_pointer( T t )
{
// implementation
} // return true or false
int a;
char *c;
SomeClass sc;
someAnotherClass *sac;
is_pointer( a ); // return false
is_pointer( c ); // return true
is_pointer( sc ); // return false
is_pointer( sac ); // return true
Run Code Online (Sandbox Code Playgroud)
我该如何实现它?谢谢
我可以用C++或C#编写iPhone应用程序吗?我在哪里可以找到iPhone的模拟器来测试我的应用程序.怎么写呢?
STLPort是否通过引用计数机制实现了字符串?
尝试调试时我有这个输出
编程接收信号SIGSEGV,分段错误0x43989029在
std :: string :: compare(这= 0x88fd430,__str = @ 0xbfff9060)
/home/devsw/tmp/objdir/i686-pc-linux-gnu/libstdc ++ - v3/include /比特/ char_traits.h:253253 {return memcmp(__ s1,__s2,__n); }
当前语言:auto; 目前是c ++
使用valgrind我得到了这个输出
== 12485 ==使用信号11的默认操作终止进程(SIGSEGV)
== 12485 = =地址0x0
= 12485 ==在0x1 处的映射区域的错误权限:(在path_to_my_executable_file/executable_file中)
我有一个Windows服务的问题,我的应用程序注册Windows服务,但当我尝试运行该服务时,我收到以下错误:"错误1053:服务没有及时响应启动或控制请求".以下代码负责注册服务(我从MSDN获得).
SC_HANDLE schSCManager;
SC_HANDLE schService;
path modulePath("some path to executable");
std::string moduleName = narrow(modulePath.native());
if(!GetModuleFileNameA(NULL, &moduleName[0], MAX_PATH))
{
throw std::runtime_error("Cannot register service, error code: " + boost::lexical_cast<std::string>(GetLastError()));
}
// Get a handle to the SCM database.
schSCManager = OpenSCManager(NULL, // local computer
NULL, // ServicesActive database
SC_MANAGER_ALL_ACCESS); // full access rights
if(!schSCManager)
{
throw std::runtime_error("OpenSCManager failed: " + boost::lexical_cast<std::string>(GetLastError()));
}
// Create the service
schService = CreateServiceA(
schSCManager, // SCM database
"name", // name of service
"displayname", // service name …Run Code Online (Sandbox Code Playgroud) 假设我们有这样的情况.假设不是"p =&global;"而是 我们调用了一些函数(由某人编写,使我们的指针无效).怎么处理这个问题?如何保护代码免受崩溃?我知道并使用boost智能指针.但是如果我们遇到这种情况该怎么办
struct Test
{
int a;
int b;
int c;
};
Test global;
int main()
{
Test *p = new Test;
p->a = 1;
p->b = 2;
p->c = 3;
p = &global;
delete p;
return 0;
}
Run Code Online (Sandbox Code Playgroud)