I'm following the GTK introduction.
My first 21 lines are:
// https://developer.gnome.org/gtk3/stable/gtk-getting-started.html#id-1.2.3.5
#include <gtk/gtk.h>
static void
print_hello (GtkWidget *widget,
gpointer data)
{
g_print ("Hello World\n");
}
static void
activate (GtkApplication* app,
gpointer user_data)
GtkWidget *window;
GtkWidget *label;
GtkWidget *button_box;
GtkWidget *button;
window = gtk_application_window_new (app);
I'm building the above gtk_hello02.c file with a makefile:
# gcc gtk_hello02.c -o gtk_hello02 `pkg-config --cflags --libs gtk+-3.0`
# https://stackoverflow.com/questions/28533059/how-to-use-pkg-config-in-make
CFLAGS=-g -Wall -Wextra $(shell pkg-config --cflags gtk+-3.0)
LDFLAGS=$(shell pkg-config --libs gtk+-3.0)
CC=gcc
SOURCES=$(wildcard *.c)
EXECUTABLES=$(patsubst %.c,%,$(SOURCES))
all: $(EXECUTABLES)
clean:
rm $(EXECUTABLES)
Why does it complain as follows?
gtk_hello02.c: In function ‘activate’:
gtk_hello02.c:21:3: error: expected declaration specifiers before ‘window’
21 | window = gtk_application_window_new (app);
| ^~~~~~
As far as I can see, the window is already declared as a GTK Widget. I remember I compiled that file without issues when I tried without the Makefile. I don't understand what changed now.