GLib 中 GHashTable 的奇怪行为

问题描述 投票:0回答:1

我正在编写一个程序,例如:

typedef struct _DsSourceBin {
  gint        index;
  gchar      *name;
  GstElement *bin;
  GstElement *src;
  gchar      *uri;
  GHashTable *config;
} DsSourceBin;

typedef struct _StreamContext {
  guint       num_source{0};
  DsSourceBin src_bin[16];
  GstElement *streammux;
  GstElement *sink;
  GstElement *primary_detector;
  GstElement *nvtile;
  GstElement *nvosd;
  gchar      *config_file;
} StreamContext;

当使用

StreamContext
时,我写道:
StreamContext ctx;
,所以在gdb中,以我的理解,我应该看到
DsSourceBin
数组的完整结构(因为隐式初始化?),但我没有: img

除非我改变我的代码,如:

GHashTable *config = NULL;
为什么会发生这种情况?有没有像 C 标准或 lib 规则之类的线索我错过了?

我也尝试删除

GHashTable*
,我可以获得
StreamContext
的完整结构: img

c data-structures struct glib
1个回答
0
投票

我解决了,这实际上是vscode C++调试器的行为:当使用GLib的发布模式时,一些调试信息将不可用,因此vscode不会显示所有这些信息,但存在的信息很少,所以在 VSCode 的调试控制台中使用 GDB 会找到我需要的信息。

© www.soinside.com 2019 - 2024. All rights reserved.