Hello,

I wrote following code:
#include <iostream>
#include <string>
#include <dirent.h>
int main()
{
struct dirent **namelist;
int numberOfProcDirs;
numberOfProcDirs=scandir("/proc", &namelist, 0, alphasort);
//std::string temp(std::string(namelist[0]->d_name)+std::string("fdsfds"));
//std::string temp(std::string(namelist[0]->d_name)+std::string("fdsf"));
// The error occured
std::string temp(std::string(namelist[0]->d_name)+std::string("cfdada"));
//std::string temp;
//temp = std::string(namelist[0]->d_name)+std::string("cfdada");
return 0;
}

When compiled under g++ 3.2, it would report compile error.

test.cpp: In function `int main()':
test.cpp:12: syntax error before `->' token

But code can compile under gcc 4.

Is this a limitation for gcc 3.2 when I used "std::string
temp(std::string(namelist[0]->d_name)+std::string("cfdada"));" to
initialize value.


Thanks,
yixuan

Reply via email to