小编Jos*_*oyd的帖子

错误:从'void*'转换为'int'会失去精度

我有一个原型函数,void* myFcn(void* arg)用作pthread的起点.我需要将参数转换为int以供以后使用:

int x = (int)arg;
Run Code Online (Sandbox Code Playgroud)

编译器(GCC版本4.2.4)返回错误:

file.cpp:233: error: cast from 'void*' to 'int' loses precision
Run Code Online (Sandbox Code Playgroud)

投这个的正确方法是什么?

c++ casting void-pointers

59
推荐指数
8
解决办法
13万
查看次数

如何在python中检查字符串是否为null

我有一个使用Python从POST调用返回的值cookie.
我需要检查cookie值是空还是null.因此,我需要if条件的函数或表达式.我怎么能用Python做到这一点?例如:

if cookie == NULL

if cookie == None
Run Code Online (Sandbox Code Playgroud)

PS cookie是存储值的变量.

python string null

12
推荐指数
2
解决办法
9万
查看次数

Gtk 进度条高度

我正在用 C++ 开发 Gtk 应用程序。(GTK 3.0)。我的问题是我无法更改 ProgressBar 高度!(https://developer.gnome.org/gtk3/stable/GtkProgressBar.html

下图将显示我所需要的。一般来说,我希望能够在我的代码中设置进度条的高度。进度条高度

我使用以下命令来编译我的示例:

gcc progress.cpp `pkg-config --cflags gtk+-3.0` `pkg-config --libs gtk+-3.0
Run Code Online (Sandbox Code Playgroud)

这是我的代码示例:

#include <gtk/gtk.h>

static gboolean
fill (gpointer   user_data)
{
  GtkWidget *progress_bar = user_data;

  /*Get the current progress*/
  gdouble fraction;
  fraction = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (progress_bar));

  /*Increase the bar by 10% each time this function is called*/
  fraction += 0.1;

  /*Fill in the bar with the new fraction*/
  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), fraction);

  /*Ensures that the fraction stays below 1.0*/
  if (fraction …
Run Code Online (Sandbox Code Playgroud)

c++ gtk gtkmm

6
推荐指数
1
解决办法
3104
查看次数

标签 统计

c++ ×2

casting ×1

gtk ×1

gtkmm ×1

null ×1

python ×1

string ×1

void-pointers ×1