C99 restrict and function parameters?

Discussion in 'C Programming' started by Sune, Feb 15, 2008.

  1. Sune

    Sune Guest

    Hi,

    I'd like to know where to put my restrict qualifier for function
    parameters.

    I have to files:

    test.h and test.c

    In test.h I have the declaration:
    void test_func( int* p);

    and in test.c I have the definition:
    void test_func( int* p)
    {
    *p += 1;
    }

    For pointer p, do I have to put the restrict qualifier in test.h or
    test.c or both?

    BRs
    /Sune
    Sune, Feb 15, 2008
    #1
    1. Advertising

  2. Sune

    santosh Guest

    Sune wrote:

    > Hi,
    >
    > I'd like to know where to put my restrict qualifier for function
    > parameters.
    >
    > I have to files:
    >
    > test.h and test.c
    >
    > In test.h I have the declaration:
    > void test_func( int* p);
    >
    > and in test.c I have the definition:
    > void test_func( int* p)
    > {
    > *p += 1;
    > }
    >
    > For pointer p, do I have to put the restrict qualifier in test.h or
    > test.c or both?


    Both. In the header it informs the user and in the implementation file
    it is obviously needed.
    santosh, Feb 15, 2008
    #2
    1. Advertising

  3. Sune

    Guest

    On 15 Feb, 18:43, santosh <> wrote:
    > Sune wrote:
    > > Hi,

    >
    > > I'd like to know where to put myrestrictqualifier for function
    > > parameters.

    >
    > > I have to files:

    >
    > > test.h and test.c

    >
    > > In test.h I have the declaration:
    > > void test_func( int* p);

    >
    > > and in test.c I have the definition:
    > > void test_func( int* p)
    > > {
    > >    *p += 1;
    > > }

    >
    > > For pointer p, do I have to put therestrictqualifier in test.h or
    > > test.c or both?

    >
    > Both. In the header it informs the user and in the implementation file
    > it is obviously needed.- Dölj citerad text -
    >
    > - Visa citerad text -


    Ok, thanks!
    /Sune
    , Mar 5, 2008
    #3
    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. tweak

    restrict keyword from ISO C99?

    tweak, Jun 19, 2004, in forum: C Programming
    Replies:
    7
    Views:
    5,199
    Dan Pop
    Jun 21, 2004
  2. C99 Restrict

    , Apr 20, 2005, in forum: C Programming
    Replies:
    1
    Views:
    523
    Christian Bau
    Apr 21, 2005
  3. Replies:
    3
    Views:
    582
    Keith Thompson
    Mar 31, 2007
  4. Replies:
    6
    Views:
    366
    Army1987
    Sep 24, 2007
  5. Adam Warner

    Correct understanding of C99's restrict?

    Adam Warner, Jun 5, 2010, in forum: C Programming
    Replies:
    9
    Views:
    471
Loading...

Share This Page