2012-07-29 78 views
1

我有在Ubuntu使用g ++ 工作正常,但未能在freebsd編譯代碼,我不知道爲什麼克++(FreeBSD的)錯誤:前預期主表達式「{」令牌

//in the source body MyClass.cpp 
     void MyClass::app_init() 
     { 

      funcs[0] = { &MyClass::app_map, 4 }; 
      funcs[1] = { &MyClass::app_pro, 10 }; 


     } 


     //in the header MyClass.h 
     public: 

     struct foo 
     { 
      int fd; 
      time_t ts; 
     }; 

     struct func 
     { 
      void (MyClass::*f) (foo *); 
      int arg_length; 
     }; 



     void app_init(); 
     void app_map(foo *a); 
     void app_pro(foo *a); 

     private: 
     func funcs[FUNCS_ARRAY]; //2 
+0

哪個字符串會導致錯誤? – ForEveR 2012-07-29 20:28:38

回答

3
funcs[0] = (func){ &MyClass::app_map, 4 }; 
... 

或編譯g++ --std=c++11 ...

相關問題