You should use the second approach like other people suggested. In your code:
GObject object = detectCollision(window, ball)
if (strcmp(getType(object), "GRect") == 0)
You didn't state that the object is the bricks. Find a way to state that and you'll be fine. Good luck.