deprecation of older C routines

T

TeamHubbell

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
 
G

Giannis Papadopoulos

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.
 
G

Giannis Papadopoulos

Giannis said:
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.
 
K

Kenneth Brody

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:[email protected]>
 
E

Emmanuel Delahaye

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"
 
A

Anonymous 7843

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.
 
K

Keith Thompson

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>
 
M

Malcolm

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top