system call to return current line number 
Author Message
 system call to return current line number

Quote:

>main()
>{
> printf("line number = %i\n",linenum());
> printf("line number = %i\n",linenum());
>}

There isn't a function call to that. It can be handle by cpp though.
Something like:

 printf("line number = %d\n",__LINE__);

Should work in most cpp's.

Roland

--
Roland J. Schemers III             | 414 Sweet Hall  +1 (415) 723-6740
Authentication Services Programmer | Stanford, CA 94305-3090

Stanford University                | http://www.*-*-*.com/ ~schemers/



Thu, 20 Feb 1997 08:22:51 GMT  
 system call to return current line number

Quote:


>>main()
>>{
>> printf("line number = %i\n",linenum());
>> printf("line number = %i\n",linenum());
>>}

>There isn't a function call to that. It can be handle by cpp though.
>Something like:
> printf("line number = %d\n",__LINE__);
>Should work in most cpp's.

Actually, since cpp resolves __LINE__ after it does the user-defined macro
substitution, you could specify:

#define linenum()       (__LINE__)

and have the original code work.  Maybe someone can flame me if this is
implementation dependent. ;)

Quote:
>Roland
>--
>Roland J. Schemers III             | 414 Sweet Hall  +1 (415) 723-6740
>Authentication Services Programmer | Stanford, CA 94305-3090

>Stanford University                | http://www-leland.stanford.edu/~schemers/

--
Wayne Berke



Sun, 23 Feb 1997 02:29:21 GMT  
 system call to return current line number

Quote:


>>main()
>>{
>> printf("line number = %i\n",linenum());
>> printf("line number = %i\n",linenum());
>>}
>There isn't a function call to that. It can be handle by cpp though.
>Something like:
> printf("line number = %d\n",__LINE__);

        To be on the safe side, use:
        printf("line number = %lu\n", (unsigned long)__LINE__);
(with an #include <stdio.h>)

        The type of the constant to which __LINE__ expands depends on the
value of __LINE__ and on the ranges of the various integral types; in the
worst case, it could be an unsigned long. But if __LINE__ really ends up
being larger than INT_MAX, it is likely that there is plenty else wrong with
the program.

PS: Strangely enough, the standard limits the parameter of a #line directive
to less than 32767, but leaves the range of __LINE__ open.

-----
/* "The world is flat, I think;    
    It is, where I am standing"
                      - an ode to the proponents of void main(void) */

/* Ajoy Krishnan T,
   Senior Software Engineer, Hughes Software Systems,
   New Delhi - 19, India.



Tue, 25 Feb 1997 23:23:00 GMT  
 system call to return current line number


: >>
: >>main()
: >>{
: >> printf("line number = %i\n",linenum());
: >> printf("line number = %i\n",linenum());
: >>}
: >>

: >There isn't a function call to that. It can be handle by cpp though.
: >Something like:

: > printf("line number = %d\n",__LINE__);

: >Should work in most cpp's.

: Actually, since cpp resolves __LINE__ after it does the user-defined
: macro substitution, you could specify:

: #define linenum()       (__LINE__)

: and have the original code work.  Maybe someone can flame me if this
: is implementation dependent. ;)

: >Roland

Roland,
   You are correct, the macros __LINE__ and __FILE__ are translated by
the preprocessor and are part of the ANSI C standard. Refer to :
Kernighan & Ritchie: The C Programming language: 2nd Edition (pg 254)
Plauger: The Standard C Library (pg 18).



Sun, 09 Mar 1997 02:01:54 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. system call to return current line number

2. system call to return current line number

3. How to get current line number??

4. Bug: Textbox.Lines.Length returns an incorrect number

5. Calling Fortran-functions returning complex numbers from C

6. printing line number of calling function ?

7. call system() in linux return code = 2560

8. Q: Return-values of system("...") calls

9. Help: C system call that returns list of all processes in Unix

10. API call to return a specific machines system clock

11. LINE -- Line Number Pipe for MS-DOS

12. LINE -- Line Number Pipe

 

 
Powered by phpBB® Forum Software