Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "glib.h"
- #include <stdio.h>
- typedef struct MyType
- {
- int a;
- }mytype_t;
- int main(int argc, char* argv[])
- {
- printf("startn");
- mytype_t myt;
- GList *l = NULL;
- for(int i=0;i<10;i++)
- {
- myt.a = i;
- l = g_list_append(l, &myt);
- }
- printf("length: %dn", g_list_length(l));
- printf("5th item a value: %dn", ((mytype_t)g_list_nth_data(l,4))->a );
- return 0;
- }
- The compiler (gcc) don`t compile it.
- output:
- gcc -o "main" "main.c" -g -Wall -std=c99 `pkg-config --cflags --libs glib-2.0` (/home/pi/projektek/glist/glist könyvtárban)
- main.c: In function ‘main’:
- main.c:26:2: error: conversion to non-scalar type requested
- printf("5th item a value: %dn", (int)((mytype_t)g_list_nth_data(l,4))->a );
- ^~~~~~
- Fordítás sikertelen.
Add Comment
Please, Sign In to add comment