deprecation of older C routines

Discussion in 'C Programming' started by TeamHubbell@charter.net, Aug 2, 2005.

  1. Guest

    Hello,

    I was wondering if anyone has some suggestions on how to deprecate C
    routines from a n already released API. I would like to be able to do
    this via the gcc compiler and be warn the end developers of the new
    routine to use if possible.


    Thanks,

    Sean
     
    , Aug 2, 2005
    #1
    1. Advertising

  2. wrote:
    > Hello,
    >
    > I was wondering if anyone has some suggestions on how to deprecate C
    > routines from a n already released API. I would like to be able to do
    > this via the gcc compiler and be warn the end developers of the new
    > routine to use if possible.
    >
    >
    > Thanks,
    >
    > Sean
    >


    It is rather OT, however what do you want to do? I think you can't do
    this without releasing a new version of the library, that has the
    necessary recommendations...

    __attribute__((__deprecated__)) void a(void) {
    }

    int main(void) {
    a();
    return 0;
    }

    --
    one's freedom stops where other's begin

    Giannis Papadopoulos
    http://dop.users.uth.gr/
    University of Thessaly
    Computer & Communications Engineering dept.
     
    Giannis Papadopoulos, Aug 2, 2005
    #2
    1. Advertising

  3. Giannis Papadopoulos wrote:
    > wrote:
    >
    >> Hello,
    >>
    >> I was wondering if anyone has some suggestions on how to deprecate C
    >> routines from a n already released API. I would like to be able to do
    >> this via the gcc compiler and be warn the end developers of the new
    >> routine to use if possible.
    >>
    >>
    >> Thanks,
    >>
    >> Sean
    >>

    >
    > It is rather OT, however what do you want to do? I think you can't do
    > this without releasing a new version of the library, that has the
    > necessary recommendations...
    >
    > __attribute__((__deprecated__)) void a(void) {
    > }
    >
    > int main(void) {
    > a();
    > return 0;
    > }
    >


    Of course, this certainly works on gcc and does not necessarily work on
    other compilers...

    --
    one's freedom stops where other's begin

    Giannis Papadopoulos
    http://dop.users.uth.gr/
    University of Thessaly
    Computer & Communications Engineering dept.
     
    Giannis Papadopoulos, Aug 2, 2005
    #3
  4. wrote:
    >
    > Hello,
    >
    > I was wondering if anyone has some suggestions on how to deprecate C
    > routines from a n already released API. I would like to be able to do
    > this via the gcc compiler and be warn the end developers of the new
    > routine to use if possible.


    This is OT to c.l.c, as it is specific to the gcc compiler and not C
    itself, but check the gcc docs for the function attribute "deprecated".

    Beyond that, there may be a gcc-specific newsgroup, should you need more
    help.

    --
    +-------------------------+--------------------+-----------------------------+
    | Kenneth J. Brody | www.hvcomputer.com | |
    | kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
    +-------------------------+--------------------+-----------------------------+
    Don't e-mail me at: <mailto:>
     
    Kenneth Brody, Aug 2, 2005
    #4
  5. wrote on 02/08/05 :
    > Hello,
    >
    > I was wondering if anyone has some suggestions on how to deprecate C
    > routines from a n already released API. I would like to be able to do
    > this via the gcc compiler and be warn the end developers of the new
    > routine to use if possible.
    >
    > Thanks,
    >
    > Sean


    AFAICT, there is no standard solution. Some compilers have a
    '__deprecated__ keyword, others have a #warning directive...

    --
    Emmanuel
    The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
    The C-library: http://www.dinkumware.com/refxc.html

    "C is a sharp tool"
     
    Emmanuel Delahaye, Aug 2, 2005
    #5
  6. In article <>,
    <> wrote:
    >
    > I was wondering if anyone has some suggestions on how to deprecate C
    > routines from a n already released API. I would like to be able to do
    > this via the gcc compiler and be warn the end developers of the new
    > routine to use if possible.


    There are several ways of dealing with this.

    Plain old text:

    if (! nag_inhibit_for_version_1_0)
    {
    printf("* You are using an old version of this API function\n");
    printf("* The new version is called Blah_Blah()\n");
    printf("* Set 'nag_inhibit_for_version_1_0' to non-zero to\n");
    printf(" prevent this message from appearing when using the\n");
    printf(" old blabla() functionality\n");
    printf("* Support for blabla() will be removed on Apr 01 2007\n");
    nag_inhibit_for_version_1_0 = 1;
    }

    A more friendly way would be to document the change and notify
    your customers/users through actual communication. Perhaps
    send out letters and announcements to paying customers or post
    to a developer email list if it's GPL or freeware.

    When possible, I like to keep the old interface around, but
    just have it make calls to the new functions. Obviously
    this is not possible if the interface changes drastically.

    If your API is implemented using a library or DLL you
    may be able to use versioning or the file name itself to
    force the end developer to pay attention to the API change.
    --
    7842++
     
    Anonymous 7843, Aug 2, 2005
    #6
  7. writes:
    > I was wondering if anyone has some suggestions on how to deprecate C
    > routines from a n already released API. I would like to be able to do
    > this via the gcc compiler and be warn the end developers of the new
    > routine to use if possible.


    There's no portable way to trigger a warning on a call to a specified
    function.

    There might be a gcc-specific way to do it. If so, it should be
    documented in the extensive documentation that comes with gcc (try
    "info gcc"); failing that, try gnu.gcc.help.

    <OT>Hint: Search for "deprecated" in the gcc documentation, and be
    prepared to skip over the first few occurrences.</OT>

    --
    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.
     
    Keith Thompson, Aug 2, 2005
    #7
  8. Malcolm Guest

    <> wrote
    >
    > I was wondering if anyone has some suggestions on how to deprecate C
    > routines from a n already released API. I would like to be able to do
    > this via the gcc compiler and be warn the end developers of the new
    > routine to use if possible.
    >

    #ifdef DEPRECATION
    #error This file has been deprecated
    #endif

    Unfortunately it only works for whole source files. You can however guard a
    function

    #ifndef DEPRECATION

    int deprecatedfunction(int x, int y)
    {
    return x == y ? x + 2 : x > y ? x + 1 : y + 1;
    }
    #endif
     
    Malcolm, Aug 3, 2005
    #8
    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. Ray Mitchell
    Replies:
    1
    Views:
    351
  2. Silas Snider

    StringBufferInputStream deprecation

    Silas Snider, Aug 25, 2004, in forum: Java
    Replies:
    2
    Views:
    4,638
    Simon Fairfax
    Aug 25, 2004
  3. e n | c k m a

    <img> deprecation

    e n | c k m a, Aug 19, 2003, in forum: HTML
    Replies:
    4
    Views:
    435
    Headless
    Aug 19, 2003
  4. fuzzylollipop
    Replies:
    3
    Views:
    1,098
    John Carson
    Jan 5, 2005
  5. Meyer, Tony

    FCNTL module deprecation warning

    Meyer, Tony, Jul 15, 2003, in forum: Python
    Replies:
    2
    Views:
    338
    Peter Hansen
    Jul 15, 2003
Loading...

Share This Page