LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   C - make - error: extra qualification â??ctrace::â?? on member â??ctraceâ?? (https://www.linuxquestions.org/questions/programming-9/c-make-error-extra-qualification-%E2-ctrace-%E2-on-member-%E2-ctrace%E2-4175438003/)

ezekieldas 11-20-2012 02:32 PM

C - make - error: extra qualification ‘ctrace::’ on member ‘ctrace’
 
1 Attachment(s)
Hi --My C was never that great but at one time I was able to hack through issues like this. That was many years ago and today I'm feeling fairly clueless about what to do with this. My questions:

1) Is there an option to tell make to ignore this sort of error?
2) If you look at trace.h (attached) there's a comment about two ctraces but only one is
used. Could this be a matter of enabling/disabling one? There's no comment about how that might be done.

This code is from: http://snarfed.org/synchronizing_mp3_playback


Code:

#p4sync-0.1> make

g++  -I. -fPIC -g -Wall  -DVERSION=\"0.1\"  -c -o client.o client.cpp
player.h:36: warning: ‘class cplayer’ has virtual functions but non-virtual destructor
trace.h:101: error: extra qualification ‘ctrace::’ on member ‘ctrace’
make: *** [client.o] Error 1


johnsfine 11-20-2012 02:39 PM

The warning on line 36 of player.h is a somewhat bogus warning. There is little correlation between the situation the compiler is complaining about and the run time bug that the compiler writers think they are helping you avoid.

The error on line 101 of trace.h is more serious, but easy to fix.

Part of the code on that line says ctrace::ctrace when it is supposed to say just ctrace

I haven't tried to find the source code. I am going entirely by the error message you quoted. If you are confused or you think I might be guessing incorrectly (which I think is unlikely) please post several lines of code from trace.h around line 101 and highlight which line exactly is line 101. Then someone could verify what I said you should change on that line.

The actual error in the code is an incorrect C++ syntax that used to be very common in C++ source code. GCC has gradually gotten stricter from version to version, old gcc just ignored the syntax error because the compiler knows what the code is supposed to mean, later gcc versions warned about that error and went on to compile the code anyway. Now (at least with the settings you used) it insists you fix that syntax error.

Quote:

Originally Posted by ezekieldas (Post 4833503)
1) Is there an option to tell make to ignore this sort of error?

I'm pretty sure there is an option to gcc to convert that error back to a warning. But I neither know the option nor how to get make to pass that option to gcc. It should be easier to just fix trace.h

Quote:

2) If you look at trace.h (attached) there's a comment about two ctraces but only one is
I don't see an attached file. I see a link to a blog and no obvious way to get trace.h from there. I didn't want to dig that much to get a line of code you should have quoted.

So I can't guess your meaning regarding "comment about two ctraces". I'm pretty sure line 101 has ctrace::ctrace where the correct C++ syntax is just ctrace

Edit: There seems to have been some lag between when you edited to add the attached file and when I got to see it. Anyway, now I see it. There is a line that looks like
Code:

  ctrace::ctrace() : out(cerr) {}
but is supposed to be
Code:

  ctrace() : out(cerr) {}
(exactly as I said before I even saw it)

The syntax of the original line is required/correct only if the line appears outside of the class definition and is defining a constructor that, inside the class definition, was declared but not defined.

The syntax without the extra ctrace:: is required/correct when declaring (or both declaring and defining) the constructor inside the class definition.

ezekieldas 11-20-2012 06:22 PM

1 Attachment(s)
Hey thanks --this was really helpful. I managed to make the change which allowed the compilation to proceed a bit further. This is maybe a different question but what I'm looking at now is:

Code:

# p4sync-0.1> make

g++  -I. -fPIC -g -Wall  -DVERSION=\"0.1\"  -c -o client.o client.cpp
player.h:36: warning: ‘class cplayer’ has virtual functions but non-virtual destructor
g++  -I. -fPIC -g -Wall  -DVERSION=\"0.1\"  -c -o player.o player.cpp
player.h:36: warning: ‘class cplayer’ has virtual functions but non-virtual destructor
player.cpp: In member function ‘void cplayer::plugin_enabled()’:
player.cpp:44: error: ‘assert’ was not declared in this scope
player.cpp: In member function ‘void cplayer::plugin_disabled()’:
player.cpp:74: error: ‘assert’ was not declared in this scope
make: *** [player.o] Error 1

I am not sure how to do this scope declaration properly. I've attached player.cpp here.


Thank you!

knudfl 11-21-2012 03:09 AM

"p4sync" : The code was edited 2 hours ago ?
https://github.com/snarfed/p4sync
1) $ git clone https://github.com/snarfed/p4sync.git
2) $ cd p4sync/ && make : No errors, no warnings.

May be you got an old version ? "p4sync-0.1" ?

bigearsbilly 11-21-2012 04:08 AM

It is not make giving you a warning, it is gnu c++

It is usually better to fix the warning rather than take the bulb out, but
you can turn them off,

If you do man g++ and search for 'Warn' you will find a load of warnings you can tailor.


I often do -Wno-parentheses
If you do a 'no' warning it needs to come after a -Wall otherwise obviously it
will be toggled back on.

pan64 11-21-2012 04:27 AM

you can check if assert.h included somewhere, probably it is missing. Otherwise you can comment out both lines in player.cpp

johnsfine 11-21-2012 06:40 AM

pan64 gave the answer I would have given if I saw your question earlier (the assert lines can be left out without damaging the program, or the proper #include could be added near the top of the .cpp file to declare assert).

But I think knudfl's answer might be better. If I understand correctly, knudfl is telling you how to get a newer version of the source code that doesn't have these problems.


All times are GMT -5. The time now is 09:02 PM.