代码之家  ›  专栏  ›  技术社区  ›  Daniel Viaño

将函数移动到不同的文件

  •  0
  • Daniel Viaño  · 技术社区  · 8 年前

    我有一个函数,可以在文件中获取三维弧中的点,但是,试图将代码排序到适当的文件夹中,我破坏了它,我不知道为什么,因为我认为我正确地包含了它。

    最初很多计算都在“messages.cpp”文件中,但它应该只有消息,并且计算应该在calculations文件夹中。

    #include "../../FGProcessorModule/Calculations/ArcToPoints.h"
    namespace myNamespace {
    void MsgProvider::onEvent{
    std::vector<Formulas::LLPoint> allPoints = ArcToPoints(center, start, end);
    }
    }
    

    在“../../FGProcessorModule/Calculations/ArcToPoints.h”中,我有:

    #ifndef ARCTOPOINTS_H
    #define ARCTOPOINTS_H
    
    #include blablabla
    
    namespace myNamespace{
    
    std::vector<Formulas::LLPoint> ArcToPoints (Formulas::LLPoint, Formulas::LLPoint, Formulas::LLPoint);
    
    }
    
    #endif /* ARCTOPOINTS_H */
    

    最后在“../../FGProcessorModule/Calculations/ArcToPoints.cpp”中,我有:

    #include "ArcToPoints.h"
    namespace myNamespace{
    std::vector<Formulas::LLPoint> ArcToPoints (Formulas::LLPoint center, Formulas::LLPoint start, Formulas::LLPoint end){
            //Lots of calculations
    }
    }
    

    我认为一切正常,但当我想要编译时,我收到了这个错误:

    未定义对“FVIS::ArcToPoints(Formulas::LLPoint,

    1 回复  |  直到 8 年前
        1
  •  0
  •   Daniel Viaño    8 年前

    我不知道这是否会帮助其他人,因为这是一个非常具体的问题,这是一个使用ros和catkin的项目。

    我在CMakeLists中丢失了新创建的文件。txt。现在它编译得很好。