我正在学习如何一起使用可重入的Bison和Flex.我已经有一个简单的计算器工作,没有可重入的功能.但是,当我激活可重入功能并进行必要的修改时,我无法使其工作.
这是代码:
scanner.l
%{
#include <stdio.h>
#include "parser.tab.h"
%}
%option 8bit reentrant bison-bridge
%option warn noyywrap nodefault
%option header-file="lex.yy.h"
DIGIT [0-9]
%%
"+" { return ADD; }
"-" { return SUB; }
"*" { return MUL; }
"/" { return DIV; }
{DIGIT}+ { *yylval = atof(yytext); return NUM; }
\n { return EOL; }
[ \t] { }
. { printf("What is this: %s.\n", yytext); }
%%
Run Code Online (Sandbox Code Playgroud)
parser.y
%{
#include <stdio.h>
#include "lex.yy.h"
void yyerror(yyscan_t scanner, char const *msg); …Run Code Online (Sandbox Code Playgroud) 是否可以获得标签尺寸?
#include <gtk/gtk.h>
GtkWidget *mainWindow, *titleLabel, *fixedFrame;
mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
//set window default size, and request size and all stuff
fixedFrame = gtk_fixed_new();
gtk_widget_set_size_request...
gtk_container_add(GTK_CONTAINER(mainWindow), fixedFrame);
titleLabel = gtk_label_new("Welcome!");
gtk_widget_set_size_request(titleLabel, x, y);
gtk_fixed_put(GTK_FIXED(fixedFrame), titleLabel, x1, y2);
Run Code Online (Sandbox Code Playgroud)
我想知道标签的大小"Welcome"(x,y),以计算框架中的正确位置,(x1,y1)但我不知道如何做到这一点.我已经尝试过在GTK文档中搜索但我没有成功.
如果Rdinput返回错误,我正试图优雅地退出我的程序.
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#define MASTER 0
#define Abort(x) MPI_Abort(MPI_COMM_WORLD, x)
#define Bcast(send_data, count, type) MPI_Bcast(send_data, count, type, MASTER, GROUP) //root --> MASTER
#define Finalize() MPI_Finalize()
int main(int argc, char **argv){
//Code
if( rank == MASTER ) {
time (&start);
printf("Initialized at %s\n", ctime (&start) );
//Read file
error = RdInput();
}
Bcast(&error, 1, INT); Wait();
if( error = 1 ) MPI_Abort(1);
//Code
Finalize();
}
Run Code Online (Sandbox Code Playgroud)
节目输出:
mpirun -np 2 code.x
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 …Run Code Online (Sandbox Code Playgroud)