[haiku-development] listsem.c doesn't compile

  • From: Pete Goodeve <pete.goodeve@xxxxxxxxxxxx>
  • To: Haiku Development <haiku-development@xxxxxxxxxxxxx>
  • Date: Tue, 6 Nov 2012 19:05:33 -0800

OK -- this I don't understand... (:-/)

I just updated my source tree and tried to compile.  It died trying to
do listsem.c:

Cc 
/boot/WORK/HAIKU_DEV/haiku/generated.x86gcc2/objects/haiku/x86/release/bin/listsem.o
 
/boot/WORK/HAIKU_DEV/haiku/src/bin/listsem.c: In function `main':
/boot/WORK/HAIKU_DEV/haiku/src/bin/listsem.c:100: warning: unused variable `sem'
/boot/WORK/HAIKU_DEV/haiku/src/bin/listsem.c:103: parse error before `int'
/boot/WORK/HAIKU_DEV/haiku/src/bin/listsem.c:105: `semID' undeclared (first use 
in this function)
/boot/WORK/HAIKU_DEV/haiku/src/bin/listsem.c:105: (Each undeclared identifier 
is reported only once
/boot/WORK/HAIKU_DEV/haiku/src/bin/listsem.c:105: for each function it appears 
in.)
/boot/WORK/HAIKU_DEV/haiku/src/bin/listsem.c:105: `info' undeclared (first use 
in this function)

So looking at the source:

listsem.c -- line 96:
                } else if (!strcmp(argv[i], "-s")) {
                        if (argc < i + 2)
                                printf("-s used without associated sem id\n");
                        else {
                                sem_id sem = atoi(argv[i+1]);

                        }
line 103:
                        int semID = atoi(argv[i+1]);
                        sem_info info;
                        if (get_sem_info(semID, &info) == B_OK) {
                                print_header(NULL);
                                print_sem_info(&info);
                        } else
                                printf("semaphore %ld unknown\n\n", semID);
                        i++;
                } else {

Hunh?  This is *C*.  How could the above code *ever* have compiled?  It has a 
declaration
following statements in the same block.

No one else hit this?

        -- Pete --

Other related posts: