armstrtw / CppBugs

c++ version of BUGS
29 stars 5 forks source link

error making tests #2

Closed yasirs closed 12 years ago

yasirs commented 12 years ago

$ make g++ -I.. -Wall -O2 -llapack linear.model.test.cpp -o linear.model.test In file included from ../cppbugs/mcmc.deterministic.hpp:21, from ../cppbugs/cppbugs.hpp:21, from linear.model.test.cpp:4: ../cppbugs/mcmc.specialized.hpp: In member function ‘double cppbugs::MCMCSpecialized<double>::mean() const’: ../cppbugs/mcmc.specialized.hpp:68: error: using ‘typename’ outside of template

error seems to be here:

for(typename std::list<double>::const_iterator it = history.begin(); it != history.end(); it++) {

armstrtw commented 12 years ago

What's your gcc version?

I have: warmstrong@krypton:~/dvl/c++/mcmc/CppBugs/test$ g++ --version g++ (Debian 4.6.2-9) 4.6.2

When I remove 'typename' I get this:

warmstrong@krypton:~/dvl/c++/mcmc/CppBugs/test$ make linear.model.test g++ -I.. -Wall -O2 linear.model.test.cpp -o linear.model.test -lblas -llapack In file included from ../cppbugs/mcmc.deterministic.hpp:21:0, from ../cppbugs/cppbugs.hpp:21, from linear.model.test.cpp:4: ../cppbugs/mcmc.specialized.hpp: In member function ‘T cppbugs::MCMCSpecialized::mean() const’: ../cppbugs/mcmc.specialized.hpp:41:11: error: need ‘typename’ before ‘std::list::const_iterator’ because ‘std::list’ is a dependent scope ../cppbugs/mcmc.specialized.hpp:41:40: error: expected ‘;’ before ‘it’ ../cppbugs/mcmc.specialized.hpp:41:62: error: ‘it’ was not declared in this scope In file included from ../cppbugs/cppbugs.hpp:27:0, from linear.model.test.cpp:4: ../cppbugs/mcmc.model.hpp: In member function ‘void cppbugs::MCModel::sample(int, int, int, int)’: ../cppbugs/mcmc.model.hpp:137:14: warning: unused variable ‘ideal_scale’ [-Wunused-variable] In file included from ../cppbugs/mcmc.deterministic.hpp:21:0, from ../cppbugs/cppbugs.hpp:21, from linear.model.test.cpp:4: ../cppbugs/mcmc.specialized.hpp: In member function ‘T cppbugs::MCMCSpecialized::mean() const [with T = arma::Col]’: linear.model.test.cpp:64:37: instantiated from here ../cppbugs/mcmc.specialized.hpp:41:60: error: dependent-name ‘std::list::const_iterator’ is parsed as a non-type, but instantiation yields a type ../cppbugs/mcmc.specialized.hpp:41:60: note: say ‘typename std::list::const_iterator’ if a type is meant make: *\ [linear.model.test] Error 1 warmstrong@krypton:~/dvl/c++/mcmc/CppBugs/test$

yasirs commented 12 years ago

This is my g++: $ g++ --ver Using built-in specs. Target: i686-apple-darwin11 Configured with: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_apple-gcc42/apple-gcc42/work/objroot/src/configure --disable-checking --prefix=/opt/local --mandir=/opt/local/share/man --enable-languages=c,c++,objc,obj-c++ --libexecdir=/opt/local/libexec/apple-gcc42 --libdir=/opt/local/lib/apple-gcc42 --includedir=/opt/local/include/apple-gcc42 --program-suffix=-apple-4.2 --with-system-zlib --disable-nls --with-gmp=/opt/local --with-mpfr=/opt/local --with-slibdir=/usr/lib --build=x86_64-apple-darwin11 --enable-werror-always --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1 Thread model: posix gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)

With the typename line (specialized.hpp:68) as for(typename std::list<double>::const_iterator it = history.begin(); it != history.end(); it++) {, I get $ make linear.model.test g++ -I.. -Wall -O2 -L/opt/local/lib -I/opt/local/include -larmadillo -llapack linear.model.test.cpp -o linear.model.test In file included from ../cppbugs/mcmc.deterministic.hpp:21, from ../cppbugs/cppbugs.hpp:21, from linear.model.test.cpp:4: ../cppbugs/mcmc.specialized.hpp: In member function 'double cppbugs::MCMCSpecialized<double>::mean() const': ../cppbugs/mcmc.specialized.hpp:68: error: using 'typename' outside of template In file included from ../cppbugs/cppbugs.hpp:27, from linear.model.test.cpp:4: ../cppbugs/mcmc.model.hpp: In member function 'void cppbugs::MCModel::sample(int, int, int, int)': ../cppbugs/mcmc.model.hpp:137: warning: unused variable 'ideal_scale' make: *** [linear.model.test] Error 1

After changing it to for(std::list<double>::const_iterator it = history.begin(); it != history.end(); it++) {, I get $ make linear.model.test g++ -I.. -Wall -O2 -L/opt/local/lib -I/opt/local/include -larmadillo -llapack linear.model.test.cpp -o linear.model.test In file included from ../cppbugs/cppbugs.hpp:27, from linear.model.test.cpp:4: ../cppbugs/mcmc.model.hpp: In member function 'void cppbugs::MCModel::sample(int, int, int, int)': ../cppbugs/mcmc.model.hpp:137: warning: unused variable 'ideal_scale'

yasirs commented 12 years ago

So I think this issue was resolved with gccc 4.6