Guest User

Untitled

a guest
Jan 17th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include "glib.h"
  2. #include <stdio.h>
  3.  
  4.  
  5.  
  6. typedef struct MyType
  7. {
  8. int a;
  9. }mytype_t;
  10.  
  11.  
  12.  
  13. int main(int argc, char* argv[])
  14. {
  15. printf("startn");
  16.  
  17. mytype_t myt;
  18.  
  19. GList *l = NULL;
  20.  
  21. for(int i=0;i<10;i++)
  22. {
  23. myt.a = i;
  24. l = g_list_append(l, &myt);
  25. }
  26.  
  27.  
  28. printf("length: %dn", g_list_length(l));
  29.  
  30. printf("5th item a value: %dn", ((mytype_t)g_list_nth_data(l,4))->a );
  31.  
  32.  
  33.  
  34. return 0;
  35. }
  36.  
  37. The compiler (gcc) don`t compile it.
  38. output:
  39. gcc -o "main" "main.c" -g -Wall -std=c99 `pkg-config --cflags --libs glib-2.0` (/home/pi/projektek/glist/glist könyvtárban)
  40. main.c: In function ‘main’:
  41. main.c:26:2: error: conversion to non-scalar type requested
  42. printf("5th item a value: %dn", (int)((mytype_t)g_list_nth_data(l,4))->a );
  43. ^~~~~~
  44. Fordítás sikertelen.
Add Comment
Please, Sign In to add comment