C++ / STL / G++ / Slackware

L

Ludis

Hi all

Im having a problem im my class "utils". Im using linux slackware 8.0
(old? yes: so old).
i trying g++ (gnu c++ compiler) 3.1 and glib default of Slack 8.0.
I cant migrate this server now, but i need to compile my class in this
machine...

See my class:


#include <iostream>
#include <fstream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>
#include <dirent.h>
class utils {
public:
void utils::cutleft(char *str, unsigned int len);
void utils::strip(char *str, char *st);
void utils::ltgt(char *str);
void utils::left(char *str, unsigned int len);
void utils::extract_mail(char *str, char *retorno);
void utils::extract_date(char *str, char *data);
void utils::split(char *linha, int separador, unsigned int index);
void utils::tira_espacos(std::string &str);
void utils::tira_espacos(char *str);
int utils::linecount(char *filename);
bool utils::deltree(char *dirname);
bool utils::file_exist(char *path);
bool utils::is_dir(char *path);
};


See my problem:


[root@test:/app/proxy]# make
g++ -Wall -c -o ../lib/utils.o ../lib/utils.cpp
In file included from ../lib/utils.cpp:1:
.../lib/utils.h:20: `::string' undeclared (first use here)
.../lib/utils.h:20: `str' was not declared in this scope
.../lib/utils.h:20: variable or field `tira_espacos' declared void
.../lib/utils.h:20: declaration of `void utils::tira_espacos(char *)'
.../lib/utils.h:21: conflicts with previous declaration `int
utils::tira_espacos'
.../lib/utils.cpp: In method `void utils::apaga_linha(char *, char *)':
.../lib/utils.cpp:218: template argument 1 is invalid
.../lib/utils.cpp:218: template argument 1 is invalid
.../lib/utils.cpp:218: template argument 2 is invalid
.../lib/utils.cpp:218: confused by earlier errors, bailing out
make: *** [../lib/utils.o] Error 1


If anyone can help-me, I will be perpetual grateful
Thanks
 
V

Victor Bazarov

Ludis said:
Im having a problem im my class "utils". Im using linux slackware 8.0
(old? yes: so old).
i trying g++ (gnu c++ compiler) 3.1 and glib default of Slack 8.0.
I cant migrate this server now, but i need to compile my class in this
machine...

See my class:


#include <iostream>
#include <fstream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>
#include <dirent.h>
class utils {
public:
void utils::cutleft(char *str, unsigned int len);

Drop the "utils::" prefices. They are unnecessary _inside_ the
class 'utils' definition.

All those 'char*' should probably be 'char const*'.
void utils::strip(char *str, char *st);
void utils::ltgt(char *str);
void utils::left(char *str, unsigned int len);
void utils::extract_mail(char *str, char *retorno);
void utils::extract_date(char *str, char *data);
void utils::split(char *linha, int separador, unsigned int index);
void utils::tira_espacos(std::string &str);

You didn't include said:
void utils::tira_espacos(char *str);
int utils::linecount(char *filename);
bool utils::deltree(char *dirname);
bool utils::file_exist(char *path);
bool utils::is_dir(char *path);
};


See my problem:


[root@test:/app/proxy]# make
g++ -Wall -c -o ../lib/utils.o ../lib/utils.cpp
In file included from ../lib/utils.cpp:1:
../lib/utils.h:20: `::string' undeclared (first use here)
../lib/utils.h:20: `str' was not declared in this scope
../lib/utils.h:20: variable or field `tira_espacos' declared void
../lib/utils.h:20: declaration of `void utils::tira_espacos(char *)'
../lib/utils.h:21: conflicts with previous declaration `int
utils::tira_espacos'
../lib/utils.cpp: In method `void utils::apaga_linha(char *, char *)':

Where is this 'method'? Next time consider reading the FAQ,
especially section 5.
../lib/utils.cpp:218: template argument 1 is invalid
../lib/utils.cpp:218: template argument 1 is invalid
../lib/utils.cpp:218: template argument 2 is invalid
../lib/utils.cpp:218: confused by earlier errors, bailing out
make: *** [../lib/utils.o] Error 1

V
 
L

Ludis

Thanks Victor Bazarov

I got success in my compilation now. Really was a problem with includes
files... lol

In slackware 10.2 it compiled without these include, perhaps because I
have included it in another archives.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top