在ncurses libreries上做一些基本的例子,我遇到了一些问题.
实际上,我没有得到我所期望的(消息打印),并且从eclipse进入调试,我得到(在控制台区域)"错误打开终端:未知."
遵循代码:
#include <unistd.h>
#include <stdlib.h>
#include <ncurses.h>
int main() {
initscr();
move(5,15);
printw("%s", "Hello world!");
refresh();
endwin();
exit(EXIT_SUCCESS);
}
Run Code Online (Sandbox Code Playgroud)
编译器选项,在Eclipse控制台的"Build project"命令中提供:
make all
Building file: ../source/Curses_01.c
Invoking: GCC C Compiler
gcc -Incurses -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"source/Curses_01.d" -MT"source/Curses_01.d" -o"source/Curses_01.o" "../source/Curses_01.c"
Finished building: ../source/Curses_01.c
Building target: Curses_01
Invoking: GCC C Linker
gcc -o"Curses_01" ./source/Curses_01.o -lcurses
Finished building target: Curses_01
Run Code Online (Sandbox Code Playgroud)
提前谢谢大家!
我正在经历这种行为.考虑这段代码
classQtData temp_data = new classData(); //consider this...
public int AddData(ref classSerialPort serial_com )
{
int return_number_of_packet_read;
int index_a;
return_number_of_packet_read = 0;
while (serial_com.GetRawData(ref raw_vector) > 0)
{
//assign temp__data stuffs....
temp_data.rolling_counter = (uint)raw_vector[40];
this.Enqueue(temp_data);
return_number_of_packet_read++;
}
return return_number_of_packet_read;
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,如果while循环执行(比如说)3次,则同一个temp_data对象(最后插入的)将被排队三次,而不是插入3个不同的对象.
否则,此代码片段按预期工作,将正确的元素排入队列:
public int AddData(ref classSerialPort serial_com )
{
int return_number_of_packet_read;
int index_a;
return_number_of_packet_read = 0;
while (serial_com.GetRawData(ref raw_vector) > 0)
{
classQtData temp_data = new classData();
//assign temp__data stuffs....
temp_data.rolling_counter = (uint)raw_vector[40];
this.Enqueue(temp_data);
return_number_of_packet_read++;
}
return return_number_of_packet_read; …Run Code Online (Sandbox Code Playgroud)