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>> 3 1432
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
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_DEPRECAT ED
Foo YourOldStupidFr oo(..);
#endif
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 and then I create a database user named setup.
I write some PHP code which should, I think, be able to to auto create
the tables.
The SQL looks like this:
|
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 operating system event viewer showing error stating that ADM5530E
The COMMIT processing of table "TBSPACEID=3.TABLEID=15107" that used
NOT LOGGED INITIALLY has been initiated. It is recommended that you
take a
backup of this table's table space(s).
since our application need to create table on the...
|
by: Rudolf Bargholz |
last post by:
Hi ,
I have the following tables
-------------
PAX:
Id
Order_Id
Name
Position
|
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, "",
"configuration on a designated vlan", PRO_REQUIRED };
const char* TOS_network_spantree_set_0_para_1_emvalue = { "disable",
"enable", NULL };
PARA TOS_network_spantree_set_0_para_1 = { "", emENUM,
TOS_network_spantree_set_0_para_1_emvalue, "", "enable or disable STP",
PRO_REQUIRED };
|
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
intention of going through whatever hell that would cause.
If I could create a large file that could be encrypted, and maybe add
files to it by appending them and putting in some kind of delimiter
between files, maybe a homemade version of truecrypt could be constructed.
Any idea what it...
| |
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 host, then check a
folder named "something" and if the folder does not exsist, create
folder "www" and then copy folder "temp" and its contents.
If the folder "www" is there, look in it, check to see if the files in
folder "temp" are in there, if not, copy the files that are not from
folder...
|
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 fixed it doesn't shows up the desired value, this is the code
that shows the compile-time error:
#include <stdio.h>
#include <string.h>
#define $WORD_LIST(X) "resource/" X
|
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
computable at load time". A warning is not equal to an error, but it usually
suggests that the code is at least questionable. I do not see anything
questionable...
This program demonstrates the issue. I get the warning whenever I pass a
pointer to a structure and use the fields of that...
|
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:
int (*callbackfunction)(const char*);
In my libary do I create a function where user passes this callback
function? How would I define the function?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |