Function prototypes

Discussion in 'C Programming' started by Jimpolar, Aug 24, 2007.

  1. Jimpolar

    Jimpolar Guest

    Well I have a design question in regards to using
    const char * for data that I am not modifying
    that I pass to a function.

    Given this prototype:
    int mvprintw(int y, int x, char *fmt [, arg] ...);

    for the format string it wants the type pointer to char
    but I have a wrapper around this function and the wrapper's
    prototype for the format string is const char *

    I don't really want to use char * because I am not modifying
    the contents of the format string, ever.

    Any suggestions on what I should do? seems the only solution
    is to use char * for my wrapper but I could cast, however
    this is even more revolting than just using char *.


    =================================================================
    My conviction comes down to this:
    we do not create terrorism by
    fighting the terrorists. We invite
    terrorism by ignoring them. And we
    will defeat the terrorists by
    capturing and killing them abroad,
    removing their safe havens and
    strengthening new allies like Iraq
    and Afghanistan in the fight we
    share.
    === GW Bush, 2005
    Jimpolar, Aug 24, 2007
    #1
    1. Advertising

  2. Jimpolar

    Ben Pfaff Guest

    Jimpolar <> writes:

    > Given this prototype:
    > int mvprintw(int y, int x, char *fmt [, arg] ...);
    >
    > for the format string it wants the type pointer to char
    > but I have a wrapper around this function and the wrapper's
    > prototype for the format string is const char *
    >
    > I don't really want to use char * because I am not modifying
    > the contents of the format string, ever.


    Assuming that mvprintw doesn't actually modify 'fmt', I'd just
    use a cast.
    --
    "A lesson for us all: Even in trivia there are traps."
    --Eric Sosman
    Ben Pfaff, Aug 24, 2007
    #2
    1. Advertising

  3. Jimpolar <> writes:
    > Well I have a design question in regards to using

    [snip]
    > =================================================================
    > My conviction comes down to this:

    [snip]
    > === GW Bush, 2005


    The correct delimiter for a signature is "-- " on a line by itself.
    Using a line of '=' characters makes the quotation look like it's part
    of the article.

    You're using slrn; it should do this for you automatically if you put
    your signature in "$HOME/.signature".

    You can put whatever you like in your signature; political discussions
    in the body of the article are frowned upon here.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Aug 24, 2007
    #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. Denis Remezov

    order of const in function prototypes

    Denis Remezov, Jun 30, 2004, in forum: C++
    Replies:
    7
    Views:
    432
    John Harrison
    Jun 30, 2004
  2. Bo Jacobsen
    Replies:
    6
    Views:
    510
    David M. Cook
    Mar 7, 2004
  3. Chris Dollin

    Re: Can function prototypes appear anywhere?

    Chris Dollin, Jan 19, 2005, in forum: C Programming
    Replies:
    3
    Views:
    353
    Michael Wojcik
    Jan 19, 2005
  4. Lawrence Kirby

    Re: Can function prototypes appear anywhere?

    Lawrence Kirby, Jan 20, 2005, in forum: C Programming
    Replies:
    2
    Views:
    332
    Lawrence Kirby
    Jan 24, 2005
  5. Syren Baran

    function prototypes and function addresses

    Syren Baran, Jan 9, 2008, in forum: C Programming
    Replies:
    6
    Views:
    307
Loading...

Share This Page