1

我的代码在 ubuntu 中使用 g++ 运行良好,但在 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
4

1 回答 1

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

或编译g++ --std=c++11 ...

于 2012-07-29T20:31:43.543 回答