[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::c_plus_plus

Title:C++
Notice:Read 1.* and use keywords (e.g. SHOW KEY/FULL KIT_CXX_VAX_VMS)
Moderator:DECCXX::AMARTIN
Created:Fri Nov 06 1987
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3604
Total number of notes:18242

3586.0. ""Type not followed by "(" in an expression" error" by HYDRA::DORHAMER () Thu May 22 1997 13:42

A software developer at Computervision reports that the following line of
code compiles successfully on all of his other UNIX systems (HP-UX, Solaris
and SGI) but gets an error from DEC C++ v5.5 on Digital UNIX:

camDoublyLinkedList_Template_t<char> input_list;

cxx: Error: test4.cxx, line 3: Type not followed by "(" in an expression.
camDoublyLinkedList_Template_t<char> input_list;
-----------------------------------^

I have his full source code, but it is quite large (many includes plus 175
lines of source).  A small test case with just this line of code generates
the same error message.  What does he need to do to get this to compile
successfully with DEC C++?  I can supply the source routine if needed.

Thanks,
Karen
    
T.RTitleUserPersonal
Name
DateLines
3586.1Type not followed by "("NNTPD::&quot;[email protected]&quot;Brian DowdTue May 27 1997 04:5927
Dear Karen,
	I had the exact same error message when I was trying to specialise the
istream_iterator<T> class to iterate over ifstreams (ifstream_iterator<T>). I
was trying to instantiate an ifstream_iterator for iterating over objects from
a "line" class (user written) as follows:

   string filename("somefile.dat");
   ifstream somefile(filename.c_str());
   ifstream_iterator<line> start (somefile);
-------------------------^

In the end I decided to use an alternative approach to the ifstream_iterator
one however, I found that just changing the last line to:

   ifstream_iterator<line()> start (somefile);

allowed the line to compile, I can only assume its something strange to
do with default ctors, I don't really understand it because ifstream_iterator
was almost exactly the same as istream_iterator, but the first form works for
istream_iterator.
	If you find any more details out I'd be interested to know.

Regards,
Brian.


[Posted by WWW Notes gateway]
3586.2We need some examples before we can diagnose the problemDECC::J_WARDTue May 27 1997 10:2843
Regarding .0 -- Can you supply us with some source code,
that reproduces the problem, i.e. the declaration the template 
class camDoublyLinkedList_Template_t? This has to
declared somewhere (i.e. in a header file) before you can use 
it to declare the input_list object.

If I create an empty class, there is no problem, i.e.:

// this compiles fine
template <class T>
class camDoublyLinkedList_Template_t {};

camDoublyLinkedList_Template_t<char> input_list;

main() {}

Regarding .1, Can you supply some source code too,
I tried this and it compiles fine with V5.5:

#include <string>
#include <iterator>
#include <fstream.h>

template <class T>
class ifstream_iterator {
public:
	ifstream_iterator(const ifstream&) {;}	
};

class line {};

int main() {
	string filename("somefile.dat");
	ifstream somefile(filename.c_str());
	ifstream_iterator<line> start (somefile);
	return 0;
}

thanks,
Judy


3586.3all setHYDRA::DORHAMERThu Jun 05 1997 12:278
    I obtained the full source and found that the header file that contains
    the declaration of the template class camDoublyLinkedList_Template_t
    does not get compiled on Digital UNIX.  When I changed the defines on
    the compile line so this header file would get compiled, the problem
    does not occur.  I've reported this back to CV.
    
    Thanks for your help,
    Karen