2012-05-01 59 views
8

如何開始使用Visual Studio 2010的tr1功能?對於更具體的情況,我需要std :: tr1 ::函數。我想包括#include <tr1/functional>該報告爲缺失,而#include <functional>包括罰款,但是當我設置:如何在Visual Studio 2010中使用tr1(tr1 :: function)?

std::tr1::function<void(void)> callback; 

我得到:

1>d:\marmalade\projects\core\src\button.h(21): error C3083: 'tr1': the symbol to the left of a '::' must be a type 
1>d:\marmalade\projects\core\src\button.h(21): error C2039: 'function' : is not a member of '_STL' 
1>d:\marmalade\projects\core\src\button.h(21): error C2143: syntax error : missing ';' before '<' 
1>d:\marmalade\projects\core\src\button.h(21): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>d:\marmalade\projects\core\src\button.h(21): error C2238: unexpected token(s) preceding ';' 

如果我使用升壓,它工作得很好,但對於這個項目,因爲使用特定的框架,我需要Visual Studio tr1版本。

至於建議,跳過TR1,仍返回相同的結果:

std::function<void(void)> callback; 

1>d:\marmalade\projects\core\src\button.h(20): error C2039: 'function' : is not a member of '_STL' 
1>d:\marmalade\projects\core\src\button.h(20): error C2143: syntax error : missing ';' before '<' 
1>d:\marmalade\projects\core\src\button.h(20): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>d:\marmalade\projects\core\src\button.h(20): error C2238: unexpected token(s) preceding ';' 
+4

'tr1'手段[技術報告1](http://en.wikipedia.org/wiki/C%2B%2B_Technical_Report_1),這是提出增加的C++標準的列表。一旦提案被接受,'tr1'的指定就會過時。 –

+0

你有沒有'包括'? –

+0

是的,我確實包括了它。 – Speed

回答

8

根據您的意見,並在this page,我認爲,果醬,用它自己的STL實現,出現過時。 This page驗證他們使用STLPort版本,該版本不支持2005年推出的TR1,更不用說更新的東西。您的選項是:

1)複製/寫那些自己
2)你不
3)Download a newer version of STLPort。它似乎並沒有已經在過去的兩年中已經更新,所以沒有C++ 11,但他們何況有functional,但並不清楚,如果它在stdstd::tr1命名空間。但是,這可能不適用於Marmalade,所以請備份並小心。

+1

我認爲它只是與STLPort([source](http://www.madewithmarmalade.com/devnet/code-community))...很糟糕。 – ildjarn

+0

確實,這很可怕:( – Speed

+2

@速度:更新的答案,更新版本的STLPort _may或可能不幫助你_ –

2

Visual Studio 2010和中附帶了C++ 11默認啓用的(或者至少是實現)。您需要使用std::function<void(void)>

對於一個完整的表see here

順便說一句:你不應該從現在TR1使用任何。它已被納入新標準。

+0

無論如何,我仍然會得到完全相同的錯誤:'std :: function callback;'返回確切的錯誤,沒有第一個錯誤:'錯誤C2039:'函數':不是'_STL''的成員 – Speed

+1

@Speed這看起來非常可疑,grep對於任何奇怪的'defined'。 – pmr

相關問題