Locally Declared Labels


 
Thread Tools Search this Thread
Top Forums Programming Locally Declared Labels
# 1  
Old 09-23-2010
Locally Declared Labels

Hi guys.

in the Locally Declared Labels section in "The Definitive Guide to GCC" book there is block of code:

Code:
#define SEARCH(array, target)
({
    __label__ found;
    typeof (target) _SEARCH_target = (target);
    typeof (*(array)) *_SEARCH_array = (array);
    int i, j;
    int value;
    for (i = 0; i < max; i++)
        for (j = 0; j < max; j++)
            if (_SEARCH_array[i][j] == _SEARCH_target)
                { value = i; goto found; }
        value = -1;
    found:
    value;
})

What the hell is the last line?
Code:
value;

# 2  
Old 09-23-2010
The last line essentially makes the macro evaluate to value, almost like it being "return value;" if SEARCH() were a function.
This User Gave Thanks to JohnGraham For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PHP: declared variables, strlen vs isset

greetings, pretty new to php and i think i might be missing some fundamental limitation of isset. i have two php scripts below that are executed by crond, one using --host X and one that does not. and below that are three different attempts at generating a command line that will be executed. the... (8 Replies)
Discussion started by: crimso
8 Replies

2. UNIX for Dummies Questions & Answers

Labels in VI

Hi, Is there a concept of lables in vi editor. In mainframes ISPF editor there is a concept of labels where one can label a line say ".a" and after that wherever you are in the file, if one want to go back to that particular line where the label was set...he could do by "l .a"....Is there... (1 Reply)
Discussion started by: whoami191
1 Replies

3. Shell Programming and Scripting

Component 'PAK_POPL_SUPPL' must be declared error

Hi, I am using a shell script to run a Oracle procedure in Linux.I am getting the below error while running the procedure: ERROR at line 1: ORA-06550: line 1, column 22: PLS-00302: component 'PAK_POPL_SUPPL' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored ... (4 Replies)
Discussion started by: csrohit
4 Replies

4. Shell Programming and Scripting

**URGENT**component 'PAK_POPL_SUPPL' must be declared error

hi, I am using a shell script to run a Oracle procedure in Linux.I am getting the below error while running the procedure: (1 Reply)
Discussion started by: csrohit
1 Replies

5. Shell Programming and Scripting

Assign user input to already declared array

What I am doing is creating a top menu, which a user will select a choice with a number entry. That number corresponds to a string in an array. I then want to assign that response to another array I've already declared. For example: #!/bin/bash colors=(red blue yellow) red=(cherry fire)... (2 Replies)
Discussion started by: Akilleez
2 Replies

6. Shell Programming and Scripting

Help in separating variables declared in the main function

Hi! I've a C program as shown below.. The line numbers and the statements of the program are separated by a space.. 1 #include<stdio.h> 2 char a,b,c; 3 float x,y,z; 4 int main() 5 { 6 int d,e,f; 7 // further declarations 8 // further declarations 9 /* body*/ 10 } 11 void fun1() 12... (1 Reply)
Discussion started by: abk07
1 Replies

7. AIX

`pthread_rwlock_t' was not declared in this scope

Hello All, I am getting this error while compiling my application on IBM AIX 5.3. As I tried to define _XOPEN_SOURCE=500 in makefile, that didn't work. Please help us to resolve the error. (0 Replies)
Discussion started by: mustus
0 Replies

8. Shell Programming and Scripting

shell script: Bind variable not declared

Hi Friends, I am trying to run a sql query from shell script as below but I get "Bind variable "1" not declared" error. 1.sh shell script has following: sDb="abc/xyz@aaa" a="1.sql" sqlplus -s $sDb @$a $1 1.sql file has following: spool Result.tmp append select cust_name from orders... (1 Reply)
Discussion started by: ppat7046
1 Replies

9. Shell Programming and Scripting

accessing variables declared in another perl script

Hi all, I have a perl script which declares two variables and calls another perl script which accesses those variables. But I am unable to access the variables in the called script. My script is as follows: my $ENV{a}="20"; system("perl called.pl"); and my called.pl contains: print... (3 Replies)
Discussion started by: gurukottur
3 Replies

10. UNIX for Dummies Questions & Answers

Tape labels

Hello using solaris 2.6 I need to know how to find out the name of DLT tapes connected to the box as dev0. It tried somethings along the lines on mt stat but to no avail. If anyone can help It would be a great help. Thanks Jonathan (1 Reply)
Discussion started by: Jonathan
1 Replies
Login or Register to Ask a Question