Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C/C++: Общие вопросы > boost::filesystem


Автор: Bogdan1024 25.3.2007, 16:41
С самого утра сегодня ставил буст. До сих пор не уверен что я его адекватно поставил. Блин, не могли уже сделать формочку с кнопкой "установить буст для VS2003 под XP", нужно им обязательно извратиться :( Делал всё как тут:
http://forum.vingrad.ru/index.php?showtopic=50550&hl=
Вооот.
Это работает (А если включить "Automaticaly generate precompiled headers", то и это не компилится.):
Код

#include "boost/filesystem/operations.hpp" // includes boost/filesystem/path.hpp
#include "boost/filesystem/fstream.hpp"    // ditto
#include <iostream>                        // for std::cout
using boost::filesystem;                   // for ease of tutorial presentation;
                                           // a namespace alias is preferred in real code
#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
    return 0;
}

Это нет:
Код

#include "boost/filesystem/operations.hpp" // includes boost/filesystem/path.hpp
#include "boost/filesystem/fstream.hpp"    // ditto
#include <iostream>                        // for std::cout
using boost::filesystem;                   // for ease of tutorial presentation;
                                       // a namespace alias is preferred in real code
#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
    remove_all( "foobar" );
    create_directory( "foobar" );
    ofstream file( "foobar/cheeze" );
    file << "tastes good!\n";
    file.close();
    if ( !exists( "foobar/cheeze" ) )
    std::cout << "Something is rotten in foobar\n";
    return 0;
}

Матюкается про код:

using boost 3.cpp(15): error C3861: 'remove_all': identifier not found, even with argument-dependent lookup
using boost 3.cpp(17): error C2065: 'ofstream' : undeclared identifier
using boost 3.cpp(17): error C2146: syntax error : missing ';' before identifier 'file'
using boost 3.cpp(19): error C2228: left of '.close' must have class/struct/union type
using boost 3.cpp(16): error C3861: 'create_directory': identifier not found, even with argument-dependent lookup
using boost 3.cpp(20): error C3861: 'exists': identifier not found, even with argument-dependent lookup
using boost 3.cpp(17): error C3861: 'file': identifier not found, even with argument-dependent lookup
using boost 3.cpp(18): error C3861: 'file': identifier not found, even with argument-dependent lookup
using boost 3.cpp(19): error C3861: 'file': identifier not found, even with argument-dependent lookup

В чём может быть проблема? Это я криво поставил, или свойства проекта нужно поменять, или ещё что-то?

Автор: Daevaorn 25.3.2007, 23:07
Цитата(Bogdan1024 @  25.3.2007,  17:41 Найти цитируемый пост)
using boost::filesystem;   

а namespace добавить не надо?)
Цитата(Bogdan1024 @  25.3.2007,  17:41 Найти цитируемый пост)
using boost 3.cpp(15): error C3861: 'remove_all': identifier not found, even with argument-dependent lookup

можно догадаться.
Цитата(Bogdan1024 @  25.3.2007,  17:41 Найти цитируемый пост)
using boost 3.cpp(17): error C2065: 'ofstream' : undeclared identifier

чистая правда, слов std нигде нет.

Автор: Любитель 25.3.2007, 23:31
Цитата(Daevaorn @  25.3.2007,  23:07 Найти цитируемый пост)
чистая правда, слов std нигде нет.

Daevaorn, в данном случае std и не должно быть. Это boost::filesystem::ofstream - работающий с boost::filesystem::path вместо строковых путей. smile

Цитата(Daevaorn @  25.3.2007,  23:07 Найти цитируемый пост)
а namespace добавить не надо?)

Конечно, надо. Риторический вопрос.

Автор: Bogdan1024 26.3.2007, 22:50
Пишу namespace - те же ошибки выдаёт. Если писать
Код

boost::filesystem::remove_all("directory");

То там целых 2 эрора:

using boost 3.cpp(15): error C2653: 'boost' : is not a class or namespace name
using boost 3.cpp(15): error C3861: 'remove_all': identifier not found, even with argument-dependent lookup

Автор: JackYF 27.3.2007, 14:51
Цитата(Bogdan1024 @  26.3.2007,  22:50 Найти цитируемый пост)
using boost 3.cpp(15): error C2653: 'boost' : is not a class or namespace name


пути-то к /boost правильно прописаны в компиляторе? он файлы-то те находит? Потому как это весьма странно smile

Автор: Fazil6 27.3.2007, 14:58
Цитата(Bogdan1024 @  25.3.2007,  16:41 Найти цитируемый пост)
#include "stdafx.h"

вообще-то это надо самой первой строкой обычно вставлять

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)