public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc (g++4.4.3) have no right to modify the name of my varialbe
@ 2010-11-04 22:55 eric lin
  2010-11-05  7:10 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: eric lin @ 2010-11-04 22:55 UTC (permalink / raw)
  To: gcc, gcc-help

dear alex:
  thanks your email, but
(1) your suggestion is not work, it still get same error
(2) g++(4.4.3) have no right to modify the name of my variable, it is "string" that I use(or Bjarne Stroustrup use)
    not "String" that gcc/g++4.4.3 show on the compiler error
(3) if I put std::string replace string on Window.cpp file, g++ will complaint
    
  root@eric-laptop:/home/eric/BStrou/usingC++4/code/Chapter12# g++ -Wno-deprecated chapter.12.3.cpp Simple_window.cpp GUI.cpp Window.cpp Graph.cpp -lfltk
Window.cpp:17: error: expected unqualified-id before ‘&’ token
Window.cpp:17: error: expected ‘)’ before ‘&’ token
Window.cpp:17: error: expected initializer before ‘&’ token
Window.cpp:25: error: expected unqualified-id before ‘&’ token
Window.cpp:25: error: expected ‘)’ before ‘&’ token
Window.cpp:25: error: expected initializer before ‘&’ token
---------------------------------------------------------------

Hy eric,
> but, there still are some compile error
> ---------------------------------------
> root@eric-laptop:/home/eric/BStrou/usingC++4/code/Chapter12# g++ -Wno-deprecated chapter.12.3.cpp  Simple_window.cpp  GUI.cpp Window.cpp -lfltk 
> Window.cpp:17: error: prototype for âGraph_lib::Window2::Window2(int, int, const String&)â does not match any in class âGraph_lib::Window2â
> Window.h:26: error: candidates are: Graph_lib::Window2::Window2(const Graph_lib::Window2&)
> Window.h:31: error:                 Graph_lib::Window2::Window2(Point, int, int, const std::string&)
> Window.h:29: error:                 Graph_lib::Window2::Window2(int, int, const std::string&)
> Window.cpp:25: error: prototype for âGraph_lib::Window2::Window2(Point, int, int, const String&)â does not match any in class âGraph_lib::Window2â
> Window.h:26: error: candidates are: Graph_lib::Window2::Window2(const Graph_lib::Window2&)
> Window.h:31: error:                 Graph_lib::Window2::Window2(Point, int, int, const std::string&)
> Window.h:29: error:                 Graph_lib::Window2::Window2(int, int, const std::string&)
> --------------------------------------------------------------------------------------
> here is my window.h and window.cpp
This are probably NOT the same files as the ones you passed to the compiler:
According to the error-message, the type "string" in Window.cpp:17 starts
with a capital letter -- in your Window.cpp that's not the case.
The same is true for Windows.cpp:25.

If those are really the correct files, I would suspect that in one of
the Header-files included in Window.cpp and NOT included in Window.h
(that is: Graph.h or GUI.h or files included into these two) you
redefine the type "string" (to be equivalent to a type "String") -- so
"string" in Window.cpp refers to a different type as "string" in
Window.h... 
If you remove the "using std::string;" in Window.h and replace all
occurences of "string" by "std::string", it should compile...

> /*****************************************************************/
> -----------------------------------Window.h---------------------
> #include <string>
> #include <vector>
> #include <FL/Fl.H>
> #include <FL/Fl_Window.H>
> #include "Point.h"
> 
> using std::string;
> namespace Graph_lib
> {
>     class Window2 : public Fl_Window { 
>     public:
>         Window2(int w, int h, const string & title);
>     };
> }
> /*****************************************************************/
> -----------------------------here is my Window.cpp-------------------
> #include <string>
> #include "Window.h"
> #include "Graph.h"
> #include "GUI.h"
> namespace Graph_lib {
> Window2::Window2(int ww, int hh, const string & title):Fl_Window(ww,hh,title.c_str()),w(ww),h(hh)
> {
>     init();
> }

Axel



_____________________________________________________________
Luxmail.com is spam free. However, we do not throw your important emails into spam box like other defective email systems.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: gcc (g++4.4.3) have no right to modify the name of my varialbe
  2010-11-04 22:55 gcc (g++4.4.3) have no right to modify the name of my varialbe eric lin
@ 2010-11-05  7:10 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2010-11-05  7:10 UTC (permalink / raw)
  To: fsshl; +Cc: gcc, gcc-help

"eric lin" <fsshl@luxmail.com> writes:

> dear alex:
>   thanks your email, but
> (1) your suggestion is not work, it still get same error
> (2) g++(4.4.3) have no right to modify the name of my variable, it is "string" that I use(or Bjarne Stroustrup use)
>     not "String" that gcc/g++4.4.3 show on the compiler error
> (3) if I put std::string replace string on Window.cpp file, g++ will complaint

Please never send e-mail to both the mailing lists gcc@gcc.gnu.org and
gcc-help@gcc.gnu.org.  This e-mail is not appropriate for
gcc@gcc.gnu.org, and should only have been sent to gcc-help.  Thanks.

g++ never changes the names of types.  If you are seeing String where
you wrote string, then some #define is in effect.

If you want help with this, you need to provide a complete standalone
test case.  However, from what I have seen so far this is not a gcc
issue, and you are asking in the wrong place.  You are having basic C++
trouble, perhaps due to a confusion of header files.  You should be
asking in a C++ or Windows help group.

Ian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-05  5:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-04 22:55 gcc (g++4.4.3) have no right to modify the name of my varialbe eric lin
2010-11-05  7:10 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).