Re: [gtk-list] Declaring widgets
- From: kosinski ugrad cs ualberta ca
- To: gtk-list <gtk-list redhat com>
- Subject: Re: [gtk-list] Declaring widgets
- Date: Sun, 25 Jul 1999 13:44:03 -0600 (MDT)
> I was just toying around with GTK and I was wondering whether you have
> to declare widgets at the top of the function. I was more or less doing
> a copy & paste thing from the tutorial and when I tried to put a
> GtkWidget *window; mid-way through a source file I started getting
> errors during compiles (error parsing * on line 288 [or something like
> that]). The problem was solved by shifting the declaration up to the top
> of the main() function but I was wondering why you had to declare
> variables at the top of a funtion, it feels like Pascal all over again
>:)
This is a C-ism. All variables have to be declared at the start of a
block, where a block is a group of code inside {}'s. So, this will work:
void test()
{
int var;
int var2;
if (var)
{
int var3;
int var4;
printf("Testing\n");
}
}
Brett.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]