From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29552 invoked by alias); 22 Nov 2003 18:25:28 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 29534 invoked from network); 22 Nov 2003 18:25:26 -0000 Received: from unknown (HELO mail-2.tiscali.it) (195.130.225.148) by sources.redhat.com with SMTP; 22 Nov 2003 18:25:26 -0000 Received: from [80.182.252.172] by mail-2.tiscali.it with HTTP; Sat, 22 Nov 2003 19:25:24 +0100 Date: Sat, 22 Nov 2003 18:25:00 -0000 Message-ID: <3FBCA56400004F14@mail-2.tiscali.it> From: codaditasso@tiscali.it Subject: FW: Re: gcc and template To: gcc-help@gcc.gnu.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="========/3FBCA56400004F14/mail-2.tiscali.it" X-SW-Source: 2003-11/txt/msg00287.txt.bz2 --========/3FBCA56400004F14/mail-2.tiscali.it Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-length: 2707 Excuse for my inaccurasy in the previous E-mail. Anyway i have obtained from compiler the following log: --------------------Configuration: prova2 - Debug-------------------- Compiling... prova8.cpp D:\Documenti\prova2\prova8.cpp: In function `void my_fun2() [with T =3D flo= at]': D:\Documenti\prova2\prova8.cpp:9: instantiated from `void my_fun1() [with T =3D float]' D:\Documenti\prova2\prova8.cpp:19: instantiated from here D:\Documenti\prova2\prova8.cpp:14: warning: unused variable `float prova' prova8.o - 2 error(s), 1 warning(s) greetings from pinzi > Thank you for your reply. > I have modify the program in the following way: > > #include > using namespace std; > > template void my_fun2(); > > template void > my_fun1(){ > my_fun2(); > }; > > template void > my_fun2(){ > T prova=3D1234; > }; > > int main() > { > my_fun1(); > return 0; > }; > > But now the compiler tell me that there is an error in my_fun2. > Please help me. > > the code above should be correct (and compiles with g++). (BTW: Please don't say "there is an error ...", but give **details**!! Just copy the error message. And perhaps better send your mail (also) to the list so that other people can participate and/or learn from it.) Oliver > > > > >-- Messaggio Originale -- > >Date: Sat, 22 Nov 2003 13:44:42 +0000 > >From: Oliver Kullmann > >To: codaditasso@tiscali.it > >Subject: Re: gcc and template > > > > > >> > > Hello > > I've tried to compile the following program with gcc: > > > > 1 template void > > 2 my_fun1(){ > > 3 my_fun2(); > > 4 }; > > 5 > > 6 template void > > 7 my_fun2(){ > > 8 T prova=3D1234; > > 9 }; > > 10 > > 11 int ma > >n() > > 12 { > > 13 my_fun1(); > > 14 > > 15 return 0; > > 16 } > > > > but the compiler tell me that there is syntax error before > in line 3. > > Anyway with the c++ builder the program was compiled correctly. What's > the > > problem? Also with t > >e mingw I've obtained the same compile error? > > In the gcc are not possible to call a template function with in another? > > > > > > Greetings from pinzi > > > > Hi, > > at line 3 you are using a non-dependent name ("my_fun2"), and non-depende= nt > names > >n template definitions are looked up immediately (while dependent > names are looked up at the point of instantiation). > > So you need to declare my_fun2 before the definition of the function temp= late > my_fun1: > > template > void my_fun2(); > > > > 1 template void > > 2 my_fun1(){ > > 3 my_fun2(); > > ... > > Oliver > > Oliver __________________________________________________________________ Tiscali ADSL SENZA CANONE, paghi solo quando navighi! E in pi=F9 il modem e' GRATIS! Abbonati subito. http://point.tiscali.it/adsl/index.shtml --========/3FBCA56400004F14/mail-2.tiscali.it Content-Type: message/rfc822 Content-Disposition: inline Content-length: 4062 Return-Path: Received: from sources.redhat.com (67.72.78.213) by mail-6.tiscali.it (6.7.019) id 3FAA85BF0103D480 for codaditasso@tiscali.it; Sat, 22 Nov 2003 18:21:34 +0100 Received: (qmail 7252 invoked by alias); 22 Nov 2003 17:21:29 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Delivered-To: mailing list gcc-help@gcc.gnu.org Received: (qmail 7245 invoked from network); 22 Nov 2003 17:21:28 -0000 Received: from unknown (HELO mhs.swan.ac.uk) (137.44.1.33) by sources.redhat.com with SMTP; 22 Nov 2003 17:21:28 -0000 Received: from cs-svr1.swan.ac.uk ([137.44.2.59]) by mhs.swan.ac.uk with esmtp (Exim 4.24) id 1ANbRo-0007Hl-1k; Sat, 22 Nov 2003 17:21:28 +0000 Received: from cs-svr1.swan.ac.uk (localhost [127.0.0.1]) by cs-svr1.swan.ac.uk (8.12.7/8.12.7/SuSE Linux 0.6) with ESMTP id hAMHLR4e020426; Sat, 22 Nov 2003 17:21:27 GMT Received: (from csoliver@localhost) by cs-svr1.swan.ac.uk (8.12.7/8.12.7/Submit) id hAMHLR7m020425; Sat, 22 Nov 2003 17:21:27 GMT Date: Sat, 22 Nov 2003 17:21:27 +0000 From: Oliver Kullmann To: gcc-help@gcc.gnu.org Subject: Re: gcc and template Message-ID: <20031122172127.GC8917@swan.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.4i X-SA-Exim-Mail-From: O.Kullmann@swansea.ac.uk Content-length: 2343 > Thank you for your reply. > I have modify the program in the following way: > > #include > using namespace std; > > template void my_fun2(); > > template void > my_fun1(){ > my_fun2(); > }; > > template void > my_fun2(){ > T prova=1234; > }; > > int main() > { > my_fun1(); > return 0; > }; > > But now the compiler tell me that there is an error in my_fun2. > Please help me. > > the code above should be correct (and compiles with g++). (BTW: Please don't say "there is an error ...", but give **details**!! Just copy the error message. And perhaps better send your mail (also) to the list so that other people can participate and/or learn from it.) Oliver > > > > >-- Messaggio Originale -- > >Date: Sat, 22 Nov 2003 13:44:42 +0000 > >From: Oliver Kullmann > >To: codaditasso@tiscali.it > >Subject: Re: gcc and template > > > > > >> > > Hello > > I've tried to compile the following program with gcc: > > > > 1 template void > > 2 my_fun1(){ > > 3 my_fun2(); > > 4 }; > > 5 > > 6 template void > > 7 my_fun2(){ > > 8 T prova=1234; > > 9 }; > > 10 > > 11 int ma > >n() > > 12 { > > 13 my_fun1(); > > 14 > > 15 return 0; > > 16 } > > > > but the compiler tell me that there is syntax error before > in line 3. > > Anyway with the c++ builder the program was compiled correctly. What's > the > > problem? Also with t > >e mingw I've obtained the same compile error? > > In the gcc are not possible to call a template function with in another? > > > > > > Greetings from pinzi > > > > Hi, > > at line 3 you are using a non-dependent name ("my_fun2"), and non-dependent > names > >n template definitions are looked up immediately (while dependent > names are looked up at the point of instantiation). > > So you need to declare my_fun2 before the definition of the function template > my_fun1: > > template > void my_fun2(); > > > > 1 template void > > 2 my_fun1(){ > > 3 my_fun2(); > > ... > > Oliver > > Oliver > > > > > > __________________________________________________________________ > Tiscali ADSL SENZA CANONE, paghi solo quando navighi! > E in piĆ¹ il modem e' GRATIS! Abbonati subito. > http://point.tiscali.it/adsl/index.shtml > > > > --========/3FBCA56400004F14/mail-2.tiscali.it--