- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在开关和结构方面有一个小问题。
我有所有指令的枚举。这重新存储在 Instr 结构中(节点地址上有 3 个指针-作为三个地址代码)
typedef enum {
// BUILT-IN FUNCTIONS
insIfj16readInt,
insIfj16readDouble,
insIfj16readString,
insIfj16lenght,
insIfj16substr,
insIfj16compare,
insIfj16find,
insIfj16sort,
insIfj16print,
//
// MATH
insPlus,
insMinus,
insMux,
insDiv,
//
//COMPARE
insEqual,
insNotEqual,
insLess,
insLessOrEqual,
insGreater,
insGreaterOrEqual,
insAssignment,
insFunctionCall
}InstrType;
typedef struct Instr {
BTSNode *Id1;
BTSNode *Id2;
BTSNode *Id3;
InstrType *type;
}Instr;
但是现在,编译器开始提示 switch 值。
切换代码是这样的:
instrStack *instrStack;
// Pointer on instruction
struct Instr *instruction;
// Taking the first instruction from the instruction stack
instruction = instrStackTop(instrStack);
while(instruction != NULL) {
instruction = instrStackTop(instrStack);
switch (instruction->type) {
// BUILT-IN FUNCTIONS
case insIfj16readInt:
if(instruction->Id3->inc == 1) {
if (instruction->Id3->data.type == var_int) {
instruction->Id3->data.value.intValue = readInt();
} else {
throwException(4,0,0);
}
} else {
throwException(8, 0, 0);
}
break;
case insIfj16readString:
etc. etc. more code and so one.
所以这是编译器的提示:
"Integer expression is required in switch instead of 'InstrType *'
我真的不知道为什么会这样。我在我的词法分析器上使用带有开关和枚举的相同“系统”(我只是改变自动机的状态),这没有问题。
最佳答案
在您的代码中,instruction->type
是 InstrType *
类型。您需要多一层取消引用。
有点像
switch ( *(instruction->type) )
应该完成这项工作。
关于C: switch 中需要整数表达式而不是 XY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40807640/
我正在尝试使用 (X,Y) 形式的 XY 点数组中的三个 XY 点找到最大面积。 我目前收到错误 called object type 'double' is not a function or fu
我在屏幕上设定的 XY 位置(例如 x=100,y=200)有一个点 (A),在屏幕上随机的 XY 位置(例如 x=50)有另一个点 (B) , y = 50)。 我想沿直线将点 B 移向点 A。 如
在我的项目中,每次打开 JSP 时我都必须分配一个变量。我用小脚本试过了 在 JSP 和 EL 中 ${}返回变量。 但是好像不行。 korrekteAntwort=${}后出现错误, 难道不
这个问题在这里已经有了答案: Bind and Destructure block arguments (3 个答案) 关闭 4 年前。 鉴于以下内容目前在 Ruby 中的工作方式类似于 Haske
#include int main(double x, double y, double x1, double y1, double x2, double y2) { // First co
我有一个函数可以根据任意数量的字典(每个字典代表图表上的一条线)生成 XY 散点图,每个字典都包含一个日期键和一个数值。到目前为止,这些值似乎在 Y 轴上有效,但日期轴 (X) 似乎已损坏。每次我从字
尝试绘制一个 xy 散点图,其中 z 值由 xy 点的颜色表示。 数据: 1.1, 32.27, 19.4 1.2, 21.34, 18 1.4, 47.45, 19.4 R代码: inp <-
我有以下代码: var favourites = JSON.parse(localStorage.getItem("favourites")); Service.all().then(function
我确实在对齐 rec 标签中的文本时遇到问题。遵循代码和两张描述案例的图片。 HTML: DACH 我确实想将文本左对齐到 rect-tag 的开头。附件是来自 Debug模式的图片,
我在 MATLAB 中有一个 x-y 散点图,想在每个点上放置一个数据标签。我似乎无法在文档中找到它。可能吗? 最佳答案 例子: p = rand(10,2); scatter(p(:,1), p(:
本文整理了Java中com.androidplot.xy.YValueMarker类的一些代码示例,展示了YValueMarker类的具体用法。这些代码示例主要来源于Github/Stackoverf
本文整理了Java中com.androidplot.xy.ZoomEstimator类的一些代码示例,展示了ZoomEstimator类的具体用法。这些代码示例主要来源于Github/Stackove
我花了很多时间寻找它,但找不到。如果这是一个基本问题,请不要轰炸我:) 我想用以下向量生成散点图 > x [1] "a" "b" "c" "d" > y [1] 5 6 3 4 我使用了 xyplot
这似乎微不足道 R问题,但我没有找到任何令人信服的解决方案。我想翻转 X 轴变为 Y 的图,反之亦然。在箱线图中有一个 horiz="T"选项,但不在 plot() 中. 这是我的情节: plot(r
This问题解释了如何在特定位置添加网格 点阵图(即相当于 两个 abline() 用于正常绘图)。我的问题是当 我尝试添加一个常规网格(相当于调用 grid() 对于正常情节)......情节的内容
我正在寻找创建 xy 图的 GWT api/示例。这是我在 powerpoint 中制作的示例图片。将有另外两个图,如下例所示,每个点都可以点击,然后在另一个图上突出显示。有没有办法在 GWT 中使用
我想将两个时间序列图表放置在彼此之上共享相同的时域轴,都具有多个数据集。 chart1 = ChartFactory.createTimeSeriesChart("", "", "", tsc1, t
我绘制了以下内容: t = data.frame(Sample=c('1','1','1','2','2','2'), X=c(12,13,14,12,11,15), Y=c(4,3,5,1,2,3)
我有一个 CAD 应用程序,我正在尝试为其构建插件,并且我需要能够选择直线和圆弧。我不能直接从应用程序中执行此操作。在我的代码中,我想开始用鼠标徒手绘制一个窗口矩形。通过 API,我可以确定刚刚绘制的
我想将 2 个变量的函数值显示为“位图”图像,例如 x+y。所以我尝试了这个,基于 http://gnuplot.sourceforge.net/demo/heatmaps.html : # Colo
我是一名优秀的程序员,十分优秀!