Hi there,
I've a 'funny' error message of my compiler (g++ 2.95.4) that tells me:
robot.cpp: In method `Robot::Robot()':
robot.cpp:19: warning: deprecated conversion from string constant to `char *'
In Line 19 of my file 'robot.cpp' I declare the constructor of class
robot like:
18
19 Robot::Robot(){
20
21 cout << "welcome to Robot's ctor!" << endl;
22
23 //do some things ...
24
25 } // end ctor
26
In line 19 are no 'strings' or 'char*s', or am I blind?
Do I call a deep hidden lib or something without knowing it?
OK, it is a warning so it seems not to be very seroius.
That was what I thougt but I was wrong!
I can compile the prog, but it does not work! :-(
The mysterious thing is, when I start the debugger I reach line 19 but
never line 20.
Thanks for reading this
Gregor (gp**@gmx.de) 15 7321
"G. Peter" <gp**@gmx.de> wrote... I've a 'funny' error message of my compiler (g++ 2.95.4) that tells me:
robot.cpp: In method `Robot::Robot()': robot.cpp:19: warning: deprecated conversion from string constant to `char
*'
In Line 19 of my file 'robot.cpp' I declare the constructor of class robot like:
18 19 Robot::Robot(){ 20 21 cout << "welcome to Robot's ctor!" << endl; 22 23 //do some things ... 24 25 } // end ctor 26
In line 19 are no 'strings' or 'char*s', or am I blind?
What's the class definition look like?
Do I call a deep hidden lib or something without knowing it?
Compilers often miscalculate the line number. Are you sure it's
that precise line?
OK, it is a warning so it seems not to be very seroius. That was what I thougt but I was wrong!
I can compile the prog, but it does not work! :-(
Unfortunately, nothing can be advised based on the amount of code
you decided to share.
The mysterious thing is, when I start the debugger I reach line 19 but never line 20.
I don't know what to tell you except, "Upgrade your compiler".
Victor
Victor Bazarov wrote: What's the class definition look like?
http://www.rob.uni-luebeck.de/~peter..._Robot/robot.h
Compilers often miscalculate the line number. Are you sure it's that precise line?
How can I?
But I am not dealing with stings at all (as far as I know :-)
Unfortunately, nothing can be advised based on the amount of code you decided to share.
For an answer I give you all the code I have
See the complete code at http://www.rob.uni-luebeck.de/~peter/Class_Robot
I don't know what to tell you except, "Upgrade your compiler".
I tried that, but that has a lot of other side effects which is topic in
a different news group ...
"G. Peter" <gp**@gmx.de> wrote... Victor Bazarov wrote:
What's the class definition look like? http://www.rob.uni-luebeck.de/~peter..._Robot/robot.h
Thanks. Doesn't help, unfortunately. Compilers often miscalculate the line number. Are you sure it's that precise line? How can I?
You could use some kind of compiler-specific macro to output
the line number (__LINE__ should expand to that). You could
put #error after that line and see if it does come to it...
But I am not dealing with stings at all (as far as I know :-)
The warning often appears at this:
char *str = "abc";
"abc" has type const char[], and 'str' is a char*. Initialisation
of a pointer to char with a pointer to (or array of) const char is
allowed but is not advised.
Unfortunately, nothing can be advised based on the amount of code you decided to share. For an answer I give you all the code I have See the complete code at
http://www.rob.uni-luebeck.de/~peter/Class_Robot
Sorry, this is not the complete code. I don't know what to tell you except, "Upgrade your compiler". I tried that, but that has a lot of other side effects which is topic in a different news group ...
Well, it's up to you then.
Victor
"G. Peter" wrote: Victor Bazarov wrote:
What's the class definition look like? http://www.rob.uni-luebeck.de/~peter..._Robot/robot.h
Compilers often miscalculate the line number. Are you sure it's that precise line? How can I?
Well.
You could comment out the line in question and see if the error goes away.
Or you could introduce an intentional error before or after the line
in question and see if the compiler emits the expected line number for
that error.
eg.
19 Robot::Robot(){
ijkl; 20 21 cout << "welcome to Robot's ctor!" << endl; 22 23 //do some things ...
Now you would expect an error at line 20 saying that identifier ijkl
is undefined. The question now is: does the compiler say: line 20
or something else?
--
Karl Heinz Buchegger kb******@gascad.at
Karl Heinz Buchegger wrote: "G. Peter" wrote:
Compilers often miscalculate the line number. Are you sure it's that precise line?
How can I?
Well. You could comment out the line in question and see if the error goes away.
Uneately this line is needed, it is the signature of the constructor.
I tried to rewrite it and reduced it to the absolute minmal without nany
changings
Or you could introduce an intentional error before or after the line in question and see if the compiler emits the expected line number for that error.
eg.
19 Robot::Robot(){
ijkl;
20 21 cout << "welcome to Robot's ctor!" << endl; 22 23 //do some things ...
Now you would expect an error at line 20 saying that identifier ijkl is undefined. The question now is: does the compiler say: line 20 or something else?
I did that and the compiler answerd:
robot.cpp:20: `ijkl' undeclared (first use this function)
So that means no miscalculation of the compiler!?!
Victor Bazarov wrote: "G. Peter" <gp**@gmx.de> wrote...
Victor Bazarov wrote:
What's the class definition look like?
http://www.rob.uni-luebeck.de/~peter..._Robot/robot.h
Thanks. Doesn't help, unfortunately. http://www.rob.uni-luebeck.de/~peter/Class_Robot
Sorry, this is not the complete code.
What else do you need?
The usesd lib 'GropLight' won't help you cause it will ask for some
certain hardware (an industrial robot you probably don't have ...)
I'll introduce the maco USE_GROPE in robot.h, if not defined it will
leave out all GropeLight specific things so it should be compileable
without the robot.
hmm ... I feel this is not done in 5 minutes, give me some time to do
that I will let you know (by sending a eMail?) if it is done ...
"Gregor Peter" <pe***@rob.uni-luebeck.de> wrote... Victor Bazarov wrote: "G. Peter" <gp**@gmx.de> wrote...
Victor Bazarov wrote:
What's the class definition look like?
http://www.rob.uni-luebeck.de/~peter..._Robot/robot.h
Thanks. Doesn't help, unfortunately.
http://www.rob.uni-luebeck.de/~peter/Class_Robot
Sorry, this is not the complete code.
What else do you need? The usesd lib 'GropLight' won't help you cause it will ask for some certain hardware (an industrial robot you probably don't have ...)
Without it I cannot compile the project.
I'll introduce the maco USE_GROPE in robot.h, if not defined it will leave out all GropeLight specific things so it should be compileable without the robot.
hmm ... I feel this is not done in 5 minutes, give me some time to do that I will let you know (by sending a eMail?) if it is done ...
Once you've done that, see if you still get the same error...
And if you do want to send me the note, pay attention to my
signature below.
Good luck!
Victor
--
Please remove capital A's from my address when replying by mail
"G. Peter" <gp**@gmx.de> wrote in message news:3E**************@gmx.de...
Victor Bazarov wrote:
What's the class definition look like? http://www.rob.uni-luebeck.de/~peter..._Robot/robot.h
Here's a guess.
CKR6 (which is a base class of Robot) Has a constructor declared something
like this
CKR6(char* something = "some_default")
This would geneate the warning mentioned and you are calling this
constructor implicitly at the start of your Robot constructor.
And if this constructor was failing, that would explain why your debug
session ends when it does.
john
"G. Peter" <gp**@gmx.de> wrote in message news:<3E**************@gmx.de>... Victor Bazarov wrote:
What's the class definition look like? http://www.rob.uni-luebeck.de/~peter..._Robot/robot.h
Compilers often miscalculate the line number. Are you sure it's that precise line? How can I? But I am not dealing with stings at all (as far as I know :-)
Unfortunately, nothing can be advised based on the amount of code you decided to share. For an answer I give you all the code I have See the complete code at
http://www.rob.uni-luebeck.de/~peter/Class_Robot
I don't know what to tell you except, "Upgrade your compiler". I tried that, but that has a lot of other side effects which is topic in a different news group ...
I notice this header file has both an include iostream.h and a using
namespace std.
#include <iostream.h>
using namespace std;
This is a real bad combination. <iostream.h> is not part of the C++
standard, and on some implementations you'll find bugs with it.
In most implementations <iostream.h> is an <iostream> version with all
the declarations in the global namespace.
If you have another source file that includes your header, and it's
using <iostream>, you could have a conflict, and the compiler may not
know which one to choose.
Unlikely that this has any thing to do with your current problem. But
you never know.
John Harrison wrote: "G. Peter" <gp**@gmx.de> wrote in message news:3E**************@gmx.de...
Here's a guess.
CKR6 (which is a base class of Robot) Has a constructor declared something like this
CKR6(char* something = "some_default")
That's it
I added the headers of the used lib on my website.
The used ctor is indeed:
CKR6(char* device = "/dev/ttyS0")
This would geneate the warning mentioned and you are calling this constructor implicitly at the start of your Robot constructor.
And if this constructor was failing, that would explain why your debug session ends when it does.
CKR6 is not written by myself, I used it in differrent projects before
with no occurance of any error (in that class) and I can't remember that
I ever got that warning before.
I did not expect (and cannot beleve it now) that the ctor of CKR6 cause
an error.
Just inheriting and (implicit) using the CKR6 ctor can't be the error,
can it?
Gregor Peter wrote: Karl Heinz Buchegger wrote: "G. Peter" wrote:
Compilers often miscalculate the line number. Are you sure it's that precise line?
How can I?
Well. You could comment out the line in question and see if the error goes away.
Uneately this line is needed, it is the signature of the constructor. I tried to rewrite it and reduced it to the absolute minmal without nany changings
Or you could introduce an intentional error before or after the line in question and see if the compiler emits the expected line number for that error.
eg.
19 Robot::Robot(){
ijkl;
20 21 cout << "welcome to Robot's ctor!" << endl; 22 23 //do some things ...
Now you would expect an error at line 20 saying that identifier ijkl is undefined. The question now is: does the compiler say: line 20 or something else?
I did that and the compiler answerd: robot.cpp:20: `ijkl' undeclared (first use this function)
So that means no miscalculation of the compiler!?!
Yes. It means that line 19 is indeed the line containing
the constructor function signature.
Thus further means you have to concentrate work on that one.
--
Karl Heinz Buchegger kb******@gascad.at
On Fri, 27 Jun 2003 11:30:25 +0200, G. Peter wrote:
John Harrison wrote: "G. Peter" <gp**@gmx.de> wrote in message news:3E**************@gmx.de...
Here's a guess.
CKR6 (which is a base class of Robot) Has a constructor declared something like this
CKR6(char* something = "some_default")
That's it I added the headers of the used lib on my website. The used ctor is indeed:
CKR6(char* device = "/dev/ttyS0")
This would geneate the warning mentioned and you are calling this constructor implicitly at the start of your Robot constructor. And if this constructor was failing, that would explain why your debug session ends when it does.
CKR6 is not written by myself, I used it in differrent projects before with no occurance of any error (in that class) and I can't remember that I ever got that warning before.
I did not expect (and cannot beleve it now) that the ctor of CKR6 cause an error.
Just inheriting and (implicit) using the CKR6 ctor can't be the error, can it?
Yes, it can, because before the derived classes are initialized, all the
bases are initialized first. So, the ctro for a derived is something like
this:
struct base {
base () {} };
struct derived: base {
derived (): base(base()) { } };
The ctor for derived expands to something like this:
derived () { this->base = base (); }
HTH,
-Dhruv.
"G. Peter" <gp**@gmx.de> wrote in message news:3E**************@gmx.de...
John Harrison wrote: "G. Peter" <gp**@gmx.de> wrote in message
news:3E**************@gmx.de... Here's a guess.
CKR6 (which is a base class of Robot) Has a constructor declared
something like this
CKR6(char* something = "some_default")
That's it I added the headers of the used lib on my website. The used ctor is indeed:
CKR6(char* device = "/dev/ttyS0")
This would geneate the warning mentioned and you are calling this constructor implicitly at the start of your Robot constructor. And if this constructor was failing, that would explain why your debug session ends when it does.
CKR6 is not written by myself, I used it in differrent projects before with no occurance of any error (in that class) and I can't remember that I ever got that warning before.
I did not expect (and cannot beleve it now) that the ctor of CKR6 cause an error.
Why not? Almost every piece of code ever written has bugs. I'm not saying
that it is a bug (it could be that you are using CKR6 inappropriately) but
its certainly worth investigating. It seems pretty clear from your debugging
that it is crashing in the CKR6 ctor. Just inheriting and (implicit) using the CKR6 ctor can't be the error, can it?
I don't know enough about how CKR6 is supposed to be used to answer that.
john
> Just inheriting and (implicit) using the CKR6 ctor can't be the error, can it?
Yes, it can, because before the derived classes are initialized, all the bases are initialized first. So, the ctro for a derived is something
like this:
struct base { base () {} };
struct derived: base { derived (): base(base()) { } };
The ctor for derived expands to something like this:
derived () { this->base = base (); }
HTH, -Dhruv.
OK that makes sense. But what can I do to avid errors here?
Does it suffice to 'pre'initialize the base class?
like main(){ static base myBase( "ttyS0" ); derived myDerived( 2.0 ) }
I'll try that ...
I think you've misunderstood Dhruv. There's no need to 'preinitialise' a
base class. I think Dhruv was just trying to point out that you are
implicitly calling the base class ctor, something you knew already I think.
john
John Harrison wrote: Just inheriting and (implicit) using the CKR6 ctor can't be the error, can it?
Yes, it can, because before the derived classes are initialized, all the bases are initialized first. So, the ctro for a derived is something
like
this:
struct base { base () {} };
struct derived: base { derived (): base(base()) { } };
The ctor for derived expands to something like this:
derived () { this->base = base (); }
HTH, -Dhruv.
OK that makes sense. But what can I do to avid errors here?
Does it suffice to 'pre'initialize the base class?
like main(){ static base myBase( "ttyS0" ); derived myDerived( 2.0 ) }
I'll try that ...
I think you've misunderstood Dhruv. There's no need to 'preinitialise' a base class. I think Dhruv was just trying to point out that you are implicitly calling the base class ctor, something you knew already I think.
john
Yes I knew that :-) but that does not solve my problem. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Anton Pervukhin |
last post by:
Hello!
Imagine the situation you have a class that interprets the command line
of the program you are executing. This class is written by third party
and has a main function parse with arguments...
|
by: frs |
last post by:
See example below: Why does the output of 'a' work and the output of
'b' fails to compile? Is there a way to write class 'something' so that
'b' converts correctly by default? (include iostream,...
|
by: djake |
last post by:
How can I convert char in wchar_t?
And how can I convert wchar_t in char?
Thanks to anyone
|
by: zhphust |
last post by:
I want to convert a object of a managed class to a unmanaged structure
that has the same member with that managed class. Can anybody tell me
how i can do it?
Thanks in advance.
--
zhphust...
|
by: Lalatendu Das |
last post by:
Dear friends,
I am getting a problem in the code while interacting with a nested
Do-while loop
It is skipping a scanf () function which it should not. I have written
the whole code below. Please...
|
by: Brennan Young |
last post by:
Hi there,
First I'll apologise for my ignorance!
I have been attempting to compile some code that I found on the net.
AFAICT it's intended to be portable code (it was available as source and...
|
by: rEvolution27 |
last post by:
I'm a c++ newbie here, trying out some stuff and when I try to compile
this:
void create() {
char name;
cout << "Creating a new timetable /n Please type a name for this
timetable";
cin >name;...
|
by: Nikola |
last post by:
Hello,
I'm writing a String class for C++ and I'm getting the following error
message when using operator:
test.cpp: In function ‘int main()’:
test.cpp:7: error: ISO C++ says that these are...
|
by: Eric |
last post by:
I am working on a large, old code base and attempting to move it to
GCC 4.2. Throughout the code, there is stuff like:
char *aVar = "aString";
or
void aFunc( char *aVar) { ... }
aFunc(...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |