我使用Ideone.com编译了下面的代码,并弹出以下警告.
rtctimer.c: In function 'rtctimer_next_tick':
rtctimer.c:87.7: warning: ignoring return value of 'read',
declared with attribute warn_unused_result [-Wunused-result]
Run Code Online (Sandbox Code Playgroud)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <poll.h>
#include <sched.h>
#include <fcntl.h>
#include <math.h>
#include <sys/ioctl.h>
#include <linux/rtc.h>
#include "rtctimer.h"
struct rtctimer_s
{
int rtc_fd;
int current_hz;
int rtc_running;
int verbose;
int usecs;
};
rtctimer_t *rtctimer_new( int verbose )
{
rtctimer_t *rtctimer = malloc( sizeof( rtctimer_t ) );
if( !rtctimer ) return 0;
rtctimer->verbose = verbose;
if( (( rtctimer->rtc_fd …Run Code Online (Sandbox Code Playgroud) GtkStyle 已被弃用。我想改用 GtkStyleContext (gtk_style_context_lookup_color) 来查找主题颜色。
我更换成功:
color = style->bg [GTK_STATE_SELECTED];
Run Code Online (Sandbox Code Playgroud)
和:
gtk_style_context_lookup_color (context, "theme_selected_bg_color", &color)
Run Code Online (Sandbox Code Playgroud)
但我不知道用什么颜色名称来替换:
color = style->dark [GTK_STATE_NORMAL];
Run Code Online (Sandbox Code Playgroud)
我需要这些颜色将它们传输到使用 cairo 创建的 vumometer:
gdk_cairo_set_source_rgba (cr, &color);
Run Code Online (Sandbox Code Playgroud) 我有一条线:
Jon Favreau, Stan Lee, Justin Theroux, Robert Downey Jr. (Tony Stark) Gwyneth Paltrow (Pepper Potts) Don Cheadle (James Rhodes)
Run Code Online (Sandbox Code Playgroud)
我想用逗号分割行,并用该结果括起来:
Jon Favreau
Stan Lee
Justin Theroux
Robert Downey Jr. (Tony Stark)
Gwyneth Paltrow (Pepper Potts)
Don Cheadle (James Rhodes)
Run Code Online (Sandbox Code Playgroud)
编辑:特殊情况
线路:Jon Favreau,Stan Lee,Justin Theroux,Robert Downey(Jr.)(Tony Stark)Gwyneth Paltrow(Pepper Potts)Don Cheadle(James Rhodes)
与世界(Jr.)在brakets.输出:
Jon Favreau
Stan Lee
Justin Theroux
Robert Downey (Jr.) (Tony Stark)
Gwyneth Paltrow (Pepper Potts)
Don Cheadle (James Rhodes)
Run Code Online (Sandbox Code Playgroud) 我继续使用以下代码获得'警告:控制到达非空函数的结尾':
static show_message(GtkMessageType type, const char* text, const char* details)
{
GtkWidget *dialog;
g_assert(text);
dialog = gtk_message_dialog_new(NULL, DIALOG_FLAGS, type, GTK_BUTTONS_CLOSE,
"%s", text);
if (details) {
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s", details);
}
gtk_dialog_run(GTK_DIALOG (dialog));
gtk_widget_destroy(dialog);
}
Run Code Online (Sandbox Code Playgroud)
当我编译上面的代码时,我得到警告(即控制到达非void函数的结尾):
gui.c: warning: return type defaults to 'int'
gui.c: In function 'show_message':
gui.c: warning: control reaches end of non-void function
Run Code Online (Sandbox Code Playgroud)
我怎么能摆脱这个警告?
谢谢.
当在预设列表中打印工作站列表并且您处于列表的开头或末尾时,您会看到许多空项目.我创建了大约20个站的列表并尝试显示它们,转到列表的开头和结尾.我认为问题在于这段代码:
static void add_button_clicked_cb(GtkWidget *widget, gpointer data)
{
preset *ps;
gchar *buffer;
GtkTreeIter iter = {0};
GtkAdjustment* v_scb;
GtkTreePath *path = NULL;
GList* menuitems;
GtkWidget *menuitem;
ps = malloc(sizeof(preset));
ps->title = g_strdup(_("unnamed"));
ps->freq = rint(gtk_adjustment_get_value(adj)) / STEPS;
settings.presets = g_list_append(settings.presets, (gpointer) ps);
buffer = g_strdup_printf("%.2f", ps->freq);
gtk_list_store_append(list_store, &iter);
gtk_list_store_set(list_store, &iter, 0, ps->title, 1, buffer, -1);
g_free(buffer);
gtk_tree_selection_unselect_all(selection);
v_scb = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(list_view));
gtk_adjustment_set_value(v_scb, gtk_adjustment_get_upper(v_scb));
if (main_visible) {
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(preset_combo), ps->title);
mom_ps = g_list_length(settings.presets) - 1;
preset_combo_set_item(mom_ps);
menuitems = gtk_container_get_children(GTK_CONTAINER(tray_menu));
menuitem = gtk_menu_item_new_with_label(ps->title);
gtk_menu_shell_insert(GTK_MENU_SHELL(tray_menu), …Run Code Online (Sandbox Code Playgroud)