472,353 Members | 1,897 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

create compiel time warning

Hi NG,

I have a library of which I want to change the name of a specific method
so it is more intuitive. I plan to keep the old method in there for now
so I won't break any existing code. But I would like to get a compile
time warning when this method is called. That way a programmer using
this library sees the warning and can change his/her code.

Is this possible and if yes, how?

Thanks in advance,
Mark
--
<<Remove the del for email>>
Jul 22 '05 #1
3 1349
Capstar wrote:

Hi NG,

I have a library of which I want to change the name of a specific method
so it is more intuitive. I plan to keep the old method in there for now
so I won't break any existing code. But I would like to get a compile
time warning when this method is called. That way a programmer using
this library sees the warning and can change his/her code.

Is this possible and if yes, how?


There is no standard way.
However, most compiler offer a pragma that can do
that.
Eg. in VC++ a line

#pragma message( "Attention" )

will output the text "Attention" during compilation.

You could now

rename the function in the library
using a macro, replace any call to the function with
the sequence
#pragma message( "Warning: old function call, use XXX instead" )
call renamed function

-
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #2
Capstar wrote:
Hi NG,

I have a library of which I want to change the name of a specific method
so it is more intuitive. I plan to keep the old method in there for now
so I won't break any existing code. But I would like to get a compile
time warning when this method is called. That way a programmer using
this library sees the warning and can change his/her code.

Is this possible and if yes, how?

In the header file do;

#ifdef ENABLE_DEPRECATED
Foo YourOldStupidFroo(..);
#endif
Jul 22 '05 #3
Karl Heinz Buchegger wrote:
Capstar wrote:

Hi NG,

I have a library of which I want to change the name of a specific method
so it is more intuitive. I plan to keep the old method in there for now
so I won't break any existing code. But I would like to get a compile
time warning when this method is called. That way a programmer using
this library sees the warning and can change his/her code.

Is this possible and if yes, how?


There is no standard way.
However, most compiler offer a pragma that can do
that.
Eg. in VC++ a line

#pragma message( "Attention" )

will output the text "Attention" during compilation.

You could now

rename the function in the library
using a macro, replace any call to the function with
the sequence
#pragma message( "Warning: old function call, use XXX instead" )
call renamed function


Since the OP didn't say which compiler he's using, but seems to have posted
from a Linux system, I'll just show the g++ way, too. It defines a specific
function attribute for this that you can use like:

void my_function() __attribute__((deprecated));

Then the compiler will issue a warning on use of that function.

Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript...
2
by: db2group88 | last post by:
hi, we install db2 udb v8.1 on windows 64bit, in our application, we have sql execute "create table .... not logged initially", but from the...
6
by: Rudolf Bargholz | last post by:
Hi , I have the following tables ------------- PAX: Id Order_Id Name Position
4
by: bingfeng | last post by:
I have some codes generated by perl, in which initialize some huge struct,such as PARA TOS_network_spantree_set_0_para_0 = { "vlan", emNUM, NULL,...
5
by: Michael Sperlle | last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems to need changes to the kernel before it can be installed, and I have no...
8
by: Paw | last post by:
Greetings. I use asp. what I need is is when a visitor comes to the site, I need it to check the host name. if "www.hometowndigest.com" is the...
9
by: Finger.Octopus | last post by:
I dont know whats terribly going wrong with this, well I know there's some memory allocation with this but I tried hard to fix it and when it gets...
2
by: copx | last post by:
What is wrong with the following code? My compiler (GCC) produces a warning which states that the initialisation values of a local struct are "not...
40
by: Angus | last post by:
Hello I am writing a library which will write data to a user defined callback function. The function the user of my library will supply is: ...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.