在MonoDevelop中,我有以下代码编译:
int[] row = new int[indices.Count]{};
Run Code Online (Sandbox Code Playgroud)
但是,在运行时,我得到:
Matrix.cs(53,53):错误CS0150:预期的常量值(CS0150)(testMatrix)
我知道这个错误意味着什么并强迫我调整数组的大小:
int[] row = new int[indices.Count]{};
Array.Resize(ref row, rowWidth);
Run Code Online (Sandbox Code Playgroud)
这是我必须处理的事情,因为我在Linux上使用MonoDevelop?我确信在.Net 3.5下我能够使用包含数组宽度的变量初始化数组.任何人都可以确认这是孤立的吗?如果是这样,我可以向bugzilla报告错误.
我有一个HttpResponse对象用于我刚刚制作的Web请求.响应采用JSON格式,因此我需要解析它.我可以以荒谬复杂的方式做到这一点,但似乎必须有更好的方法.
这真的是我能做的最好的吗?
HttpResponse response; // some response object
Reader in = new BufferedReader(
new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
StringBuilder builder= new StringBuilder();
char[] buf = new char[1000];
int l = 0;
while (l >= 0) {
builder.append(buf, 0, l);
l = in.read(buf);
}
JSONTokener tokener = new JSONTokener( builder.toString() );
JSONArray finalResult = new JSONArray( tokener );
Run Code Online (Sandbox Code Playgroud)
我在Android上,如果这有任何区别.
我有一个头文件BKE_mesh.h的以下块:
/* Connectivity data */
typedef struct IndexNode {
struct IndexNode *next, *prev;
int index;
} IndexNode;
void create_vert_face_map(ListBase **map, IndexNode **mem, const struct MFace *mface,
const int totvert, const int totface);
void create_vert_edge_map(ListBase **map, IndexNode **mem, const struct MEdge *medge,
const int totvert, const int totedge);
Run Code Online (Sandbox Code Playgroud)
请注意,头文件是为准备在C++文件中使用而准备的,因为它具有:
#ifdef __cplusplus
extern "C" {
#endif
Run Code Online (Sandbox Code Playgroud)
在文件的顶部,以及底部所需的完成.但实现它的类是用C语言编写的.
接下来,每当我尝试#include头文件时,我都会遇到奇怪的错误.如果文件的扩展名为.cpp,则编译得很好,没有任何投诉.但是,如果我这样做:
#include "BKE_mesh.h"
Run Code Online (Sandbox Code Playgroud)
在.c扩展名的文件中,我收到以下错误:
expected ')' before '*' token
Run Code Online (Sandbox Code Playgroud)
对于最后两个函数,具体来说,变量:
ListBase **map
Run Code Online (Sandbox Code Playgroud)
在这两个班级.(注意,在头文件的早期,它已声明,但未定义ListBase).
所以,我的问题是:为什么这是有效的C++代码,而不是C代码?
谢谢.
所以我的问题是,为什么要使用接口或抽象类?为什么它们有用,为什么?
我在哪里可以聪明地使用它们?
我正在开发一个基于localStorage HTML5功能的简单TODO列表应用程序:
http://hamen.github.com/webnotes/
我想知道是否可以以某种方式导入/导出数据.我如何提供"导出注释/导入注释"功能,以使用户能够将注释保存在其HD上并将其导入其他浏览器配置文件中?
谢谢
我对AlarmManager有一个奇怪的情况.我正在使用AlarmManager安排一个事件,并使用intent.putExtra传入一个字符串.弦是静音或振动的,当接收器发出电话时,应该转动振铃器或将手机设置为振动.log语句每次都正确输出预期值.
Intent intent;
if (eventType.equals("start")) {
intent = new Intent(context, SReceiver.class);
} else {
intent = new Intent(context, EReceiver.class);
}
intent.setAction(eventType+Long.toString(newId));
Log.v("EditQT",ringerModeType.toUpperCase());
intent.putExtra("ringerModeType", ringerModeType.toUpperCase());
PendingIntent appIntent = PendingIntent.getBroadcast(context, 0,
intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService (Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
appIntent);
Run Code Online (Sandbox Code Playgroud)
在警报执行时触发的接收器也有一个日志语句,我可以看到第一次该语句输出预期的字符串SILENT或VIBRATE但是对于每次后续执行,输出显示接收器端的原始值.警报执行然后我将putExtra的值更改为相反的字符串,并且接收器仍然显示先前的值事件,尽管来自上面代码的调用显示传入了新值.setAction的值每次都相同.
audioManager = (AudioManager) context.getSystemService(Activity.AUDIO_SERVICE);
Log.v("Start",intent.getExtras().get("ringerModeType").toString());
if (intent.getExtras().get("ringerModeType").equals("SILENTMODE")) {
audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
} else {
audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
}
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?
我使用VS2008/VS2010与Resharper 5,TortoiseSVN 1.6.8.19260-x64和AnkhSVN 2.1.8420.8.我在Visual Studio中执行的大多数操作都在SVN中很好地反映了,但是,当我尝试提交更改时,重命名项目中的文件夹会导致问题.此外,还需要更新重命名文件夹下的C#源文件中的所有命名空间以反映名称更改.
重命名主项目文件夹或任何子文件夹的最佳方法是什么,并确保SVN没有问题?它应该在Visual Studio之外完成吗?
更新所有命名空间更改的最佳方法是什么?搜索/替换是唯一的方法吗?
有关文件夹名称及其内容的最佳做法吗?
我想用指针参数初始化一个链表,如下所示:
/*
* Initialize a linked list using variadic arguments
* Returns the number of structures initialized
*/
int init_structures(struct structure *first, ...)
{
struct structure *s;
unsigned int count = 0;
va_list va;
va_start(va, first);
for (s = first; s != NULL; s = va_arg(va, (struct structure *))) {
if ((s = malloc(sizeof(struct structure))) == NULL) {
perror("malloc");
exit(EXIT_FAILURE);
}
count++;
}
va_end(va);
return count;
}
Run Code Online (Sandbox Code Playgroud)
问题是,铛错误type name requires a specifier or qualifier的va_arg(va, (struct structure *)) …
我有一个具有此值的字符串:
2010-05-13 23:17:29
Run Code Online (Sandbox Code Playgroud)
我想格式化它并使用以下代码:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateStyle = NSDateFormatterMediumStyle;
NSDate *formattedDate = [formatter dateFromString:dateString];
[formatter release];
Run Code Online (Sandbox Code Playgroud)
当调试器到达释放行时,formattedDate显示"invalid CFStringRef"和
Cannot access memory at address 0x0
Run Code Online (Sandbox Code Playgroud)
我有什么想法我做错了吗?
我在*nix上看到的所有内容都是关于硬件的一组抽象,但我很好奇硬件是如何工作的.
我已经在汇编中进行了编程,但这仍然只是一组抽象.
处理器如何理解汇编操作码(如字节码)?
设备驱动程序如何工作(在较低级别(抽象)进行解释)?
android ×2
c ×2
c# ×2
abstraction ×1
alarmmanager ×1
ankhsvn ×1
arrays ×1
assembly ×1
c++ ×1
c99 ×1
cocoa-touch ×1
hardware ×1
header ×1
html5 ×1
interface ×1
iphone ×1
java ×1
javascript ×1
json ×1
linked-list ×1
monodevelop ×1
nsdate ×1
objective-c ×1
oop ×1
opensuse ×1
svn ×1
tortoisesvn ×1