macros

Discussion in 'C Programming' started by Bill Cunningham, Oct 16, 2003.

  1. I was browsing the linux kernel source and came across something I've never
    seen. Here's an example

    #define (thismacro)
    #define (1<<(thismacro))

    What is this doing? Why the parenthesis around the macro defines, on each
    line?

    Bill





    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
     
    Bill Cunningham, Oct 16, 2003
    #1
    1. Advertising

  2. Bill Cunningham <> scribbled the following:
    > I was browsing the linux kernel source and came across something I've never
    > seen. Here's an example


    > #define (thismacro)
    > #define (1<<(thismacro))


    > What is this doing? Why the parenthesis around the macro defines, on each
    > line?


    I don't think #define (1<<(thismacro)) is valid C syntax at all.

    --
    /-- Joona Palaste () ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "I am looking for myself. Have you seen me somewhere?"
    - Anon
     
    Joona I Palaste, Oct 16, 2003
    #2
    1. Advertising

  3. On Thu, 16 Oct 2003 02:32:43 -0400, Bill Cunningham wrote:

    > I was browsing the linux kernel source and came across something I've never
    > seen. Here's an example
    >
    > #define (thismacro)
    > #define (1<<(thismacro))
    >
    > What is this doing? Why the parenthesis around the macro defines, on each
    > line?


    Doesn't look like C, are you sure you didn't miss anything in your
    example? It might be a gcc specific thing though, but a quick glance at
    the gcc info pages didn't shed any light on it.

    Looking at the actual usage instead of your example might help shed some
    light on it.
    Kernel version?
    File?
    Line?

    regards
    --
    NPV

    "the large print giveth, and the small print taketh away"
    Tom Waits - Step right up
     
    Nils Petter Vaskinn, Oct 16, 2003
    #3
  4. Joona I Palaste <> spoke thus:

    >> #define (thismacro)
    >> #define (1<<(thismacro))


    > I don't think #define (1<<(thismacro)) is valid C syntax at all.


    Neither is #define (thismacro), for that matter, right? gcc says that macro
    names must be identifiers...
    --
    Christopher Benson-Manica | I *should* know what I'm talking about - if I
    ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
     
    Christopher Benson-Manica, Oct 16, 2003
    #4
  5. "Nils Petter Vaskinn" <> wrote in message
    news:p...
    > On Thu, 16 Oct 2003 02:32:43 -0400, Bill Cunningham wrote:
    >
    > > I was browsing the linux kernel source and came across something I've

    never
    > > seen. Here's an example
    > >
    > > #define (thismacro)
    > > #define (1<<(thismacro))
    > >
    > > What is this doing? Why the parenthesis around the macro defines, on

    each
    > > line?

    >
    > Doesn't look like C, are you sure you didn't miss anything in your
    > example? It might be a gcc specific thing though, but a quick glance at
    > the gcc info pages didn't shed any light on it.
    >
    > Looking at the actual usage instead of your example might help shed some
    > light on it.
    > Kernel version?
    > File?
    > Line?
    >
    > regards

    It figures. Now I can't find it but I believe it had something to do with
    sys calls or calling sys calls. I'll keep looking. I'm almost sure I've seen
    code like

    #define (something)

    before in a header or source file. But if it's a syntax error, maybe I'm
    mistaken.

    Bill





    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
     
    Bill Cunningham, Oct 16, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    80
    Views:
    2,436
    Stephen J. Bevan
    Nov 7, 2003
  2. Replies:
    1
    Views:
    453
    Marco Antoniotti
    Oct 7, 2003
  3. Replies:
    5
    Views:
    498
  4. Michael T. Babcock

    Re: Explanation of macros; Haskell macros

    Michael T. Babcock, Nov 3, 2003, in forum: Python
    Replies:
    0
    Views:
    521
    Michael T. Babcock
    Nov 3, 2003
  5. Andrew Arro

    macros-loop? calling macros X times?

    Andrew Arro, Jul 23, 2004, in forum: C Programming
    Replies:
    2
    Views:
    498
    S.Tobias
    Jul 24, 2004
Loading...

Share This Page