是否有简单的工具,可用于确定函数的调用位置,函数调用的其他函数...?
编辑:我正在使用Mac OS X(10.6)并且只想进行静态分析.
谢谢!
在C++中是否有一种将错误代码转换为字符串以显示它的常用方法?
我看到某个err2msg功能,有一个大开关,但这真的是最好的方法吗?
在Objective-C++中禁止将C++引用类型作为实例变量.我该如何解决这个问题?
想象一下这个简单的基类:
struct simple_http_service
{
virtual reply http_get(…);
virtual reply http_post(…);
virtual reply http_delete(…);
// etc.
};
Run Code Online (Sandbox Code Playgroud)
我想阻止用户从这个类派生而不至少覆盖其中一个并阻止他们实例化 simple_http_service
有一些很好的方法来做到这一点?
当尝试在命令行上使用ant构建Apache FOP时,它会抱怨:
[javac] The system is out of resources.
[javac] Consult the following stack trace for details.
[javac] ...
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:353)
Run Code Online (Sandbox Code Playgroud)
我不明白.我有足够的RAM,系统如何耗尽资源?
我编写的代码如下所示:
template<typename CocoaWidget>
class Widget : boost::noncopyable
{
private:
CocoaWidget* mCocoaWidget;
public:
Widget()
{
mCocoaWidget = [[CocoaWidget alloc] init];
}
// ...
};
class Button : Widget<NSButton>
{
// ...
};
Run Code Online (Sandbox Code Playgroud)
但这不起作用,因为Mac开发中心说:
Objective-C类,协议和类别不能在C++模板中声明
那我现在最好做什么呢?
我的代码:
*的.aspx:
<asp:DropDownList ID="CountryList" CssClass="CountryList" runat="server"
OnSelectedIndexChanged="CountryList_SelectedIndexChanged" />
Run Code Online (Sandbox Code Playgroud)
*.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
CountryList.SelectedIndexChanged +=
new EventHandler(CountryList_SelectedIndexChanged);
...
}
protected void CountryList_SelectedIndexChanged(object sender, EventArgs e)
{
LoadCityList(CountryList, CityList);
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用.
我想指定的HTML id中ActionLink,但我不能这样做:
@html.ActionLink("Controller", "Action", new {@id = "tec"})
Run Code Online (Sandbox Code Playgroud)
因为这@id意味着参数tec值id.
另一方面,如果我这样做
@html.ActionLink("Controller", "Action", new {@class = "tec"})
Run Code Online (Sandbox Code Playgroud)
结果将是:
<a href="Controller/Action" class="tec"></a>
Run Code Online (Sandbox Code Playgroud)
你知道一种指定html id的方法吗?
我想这个结果:
<a href="Controller/Action" id="tec"></a>
Run Code Online (Sandbox Code Playgroud) 假设这段代码:
static inline void inc(int64_t* atomic)
{
__asm__ __volatile__
(
"lock incq %0\n"
: "=m" (*atomic)
: "m" (*atomic)
);
}
Run Code Online (Sandbox Code Playgroud)
Clang编译器不支持锁前缀(还是?).我现在该怎么办?
我真的不明白cocoa在通知和事件之间的区别.
例如,我可以有这样的代码:
-(void)mouseMoved:(NSEvent*)event { … }
Run Code Online (Sandbox Code Playgroud)
但不是
-(void)windowMoved:(NSEvent*)event { … }
Run Code Online (Sandbox Code Playgroud)
对于第二个我必须使用NSNotification - 为什么?
对于C++代码,我可以使用placement new/delete运算符及其arraycounterparts来自行管理内存.
现在我想将我的内存管理器也用于Objective-C代码.我想过要替换NSObject alloc:和dealloc:方法,但poseAsClass:不再工作了.那么:我如何使用我的内存管理器强制它?还是我完全走错了路?
我在C中编写的代码中使用运算符' - >'时得到了这种奇怪的副作用.我使用的指针 - > on,被改为有一些垃圾.
进一步来说:
我有以下结构:
typedef void* ListElement ;
typedef struct List_t* List ;
typedef struct Node_t* Node;
Struct Node_t {
ListElement data ;
Node next;
}
Struct List_t {
Node* head;
Node* current
}
Run Code Online (Sandbox Code Playgroud)
当我使用以下内容时ListGetFirst(),我得到了有线行为:
ListElement ListGetFirst(List list)
{
if( list == NULL || list->head==NULL)
{
return NULL;
}
list->current=list->head;
Node* head =list->head; // here is the problem
ListElement data = (*head)->data;
return data;
}
Run Code Online (Sandbox Code Playgroud)
当我使用调试器时,我发现指针列表 - >头部在标记的前述行上发生了变化.
我真的不知道为什么,而且我不知道' - >'会有副作用
提前致谢
我有以下C++代码:
#include <iostream>
#include <vector>
using namespace std;
class A
{
private:
int i;
public:
void f1(const A& o);
void f2()
{
cout<<i<<endl;
}
};
void A::f1(const A& o)
{
o.f2();
}
Run Code Online (Sandbox Code Playgroud)
它只是不编译.有人可以解释一下吗?谢谢!
c++ ×8
objective-c ×3
assembly ×1
c ×1
c# ×1
clang ×1
cocoa ×1
events ×1
java ×1
linked-list ×1
nsevent ×1
nsobject ×1
overriding ×1
pointers ×1
razor ×1
side-effects ×1
templates ×1