Re: Function not definen in current scope

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Sun, 21 Mar 2010 14:50:15 -0500


Hi Cedric,

Cint is technically correct in this case and the compiler agrees. Attempting to compile:

void test2() {
const int cols[ ]={ 1,2 };
deque< float >* myData = deCASSYfy( "E:\\mydocs\\cassy.lab",cols,2 ); }

leads to the slightly more explicit message:

/private/var/tmp/./test.C: In function ‘void test2()’: /private/var/tmp/./test.C:53: error: no matching function for call to ‘deCASSYfy(const char [20], const int [2], int)’ /private/var/tmp/./test.C:17: note: candidates are: std::deque<float, std::allocator<float> >* deCASSYfy(const char*, const char*, unsigned int) /private/var/tmp/./test.C:22: note: std::deque<float, std::allocator<float> >* deCASSYfy(std::ifstream&, const char* const&, unsigned int)
/private/var/tmp/./test.C:53: warning: unused variable ‘myData’

The problem is that you need to define 'cols' as a "const char int[] = {1,2}

Cheers,
Philippe.

On 3/21/10 11:30 AM, Cedric Sodhi wrote:
> I'm unfortuanlly not getting anywhere even after I've simplified the
> code as Axel suggested. It now reads:
>
> #include <deque>
> #include <sstream>
> #include <fstream>
> #include <algorithm>
>
> void test( ) { std::cout << "LOADED cassy.h" << std::endl; }
>
> std::deque< float >* deCASSYfy( const char*,const char* const&,const
> unsigned int );
> std::deque< float >* deCASSYfy( std::ifstream&,const char*
> const&,const unsigned int );
>
> std::deque< float >* deCASSYfy( const char *inFile,const char* const&
> cols,const unsigned int colcnt ) {
> std::ifstream dataFile( inFile );
> return deCASSYfy( dataFile,cols,colcnt );
> }
>
> std::deque< float >* deCASSYfy( std::ifstream& inFile,const char*
> const& cols,const unsigned int colcnt ) {
> if( !inFile.good( ) )
> throw "Filestram could not be read";
> std::cout << sizeof( cols );
> std::deque< float > *dataSet = new std::deque< float >( );
> std::string lastLine;
> float lastVal = 0;
> while( std::getline( inFile,lastLine ) ) {
> unsigned int fieldPos = 0;
> unsigned int j = 0;
> if( lastLine.find( "\t" )!= std::string::npos ) {
> for( unsigned int i = 0; j < colcnt; i++ )
> if( fieldPos != std::string::npos ) {
> std::istringstream lastField( lastLine.substr( fieldPos ) );
> fieldPos = lastLine.find( "\t",fieldPos + 1 );
> if( std::find( cols,cols + colcnt,i )!=( cols + colcnt ) ) {
> lastField >> std::scientific >> lastVal;
> dataSet->push_back( lastVal );
> j++;
> }
> } else {
> dataSet->push_back( 0.0 );
> j++;
> }
> }
> }
> return dataSet;
> }
>
> -----
> Yet, I get
>
> root [0] #include "E:\mydocs\Programs\Akustik\cassy.h";
> root [1] test( );
> LOADED cassy.h
> root [2] const int cols[ ]={ 1,2 };
> root [3] deque< float >* myData = deCASSYfy(
> "E:\\mydocs\\cassy.lab",cols,2 );
> Error: Function deCASSYfy("E:\\mydocs\\cassy.lab",cols,2) is not
> defined in curr
> ent scope (tmpfile)(1)
> *** Interpreter error recovered ***
> root [4]
>
Received on Sun Mar 21 2010 - 20:50:21 CET

This archive was generated by hypermail 2.2.0 : Sun Mar 21 2010 - 23:50:02 CET