在C文件中找不到头文件中定义的结构

时间:2018-03-14 09:08:09

标签: c

我创建了一个头文件,我在其中定义了一个名为CtrlStruct的结构:

typedef struct CtrlStruct
{
    CtrlIn *inputs;   ///< controller inputs
    CtrlOut *outputs; ///< controller outputs
    RobotPosition *rob_pos; ///< robot position
    OpponentsPosition *opp_pos; ///< opponents position
    SpeedRegulation *sp_reg; ///< speed regulation
    RobotCalibration *calib; ///< calibration
    PathPlanning *path; ///< path-planning
    Strategy *strat; ///< strategy
    int main_state; ///< main state
    int robot_id;   ///< ID of the robot
    int team_id;    ///< ID of the team
} CtrlStruct;

然后我在我的C文件中使用这个结构,并在我的C文件中包含标题(C文件和标题具有相同的名称)。尽管如此,我的编译器无法识别这种结构。

#include "CtrlStruct_gr7.h"
#include "namespace_ctrl.h"
#include "init_pos_gr7.h"
#include "odometry_gr7.h"
#include "opp_pos_gr7.h"
#include "speed_regulation_gr7.h"
#include "calibration_gr7.h"
#include "strategy_gr7.h"
#include "path_planning_gr7.h"
#include "ctrl_io.h"

NAMESPACE_INIT(ctrlGr7);

/*! \brief initialize the controller structure
*
* \param[in] inputs inputs of the controller
* \param[in] outputs outputs of the controller
* \return controller main structure
*
* Many parameters are set to arbitrary values, which will be corrected in 'controller_init'.
*/
CtrlStruct* init_CtrlStruct(CtrlIn *inputs, CtrlOut *outputs)
{
    int i;
    CtrlStruct* cvs;

    cvs = (CtrlStruct*)malloc(sizeof(CtrlStruct));

有人知道它应该是什么吗?

1 个答案:

答案 0 :(得分:-2)

您有命名问题 应该是:

struct CtrlStruct
{
CtrlIn *inputs;   ///< controller inputs
CtrlOut *outputs; ///< controller outputs
RobotPosition *rob_pos; ///< robot position
OpponentsPosition *opp_pos; ///< opponents position
SpeedRegulation *sp_reg; ///< speed regulation
RobotCalibration *calib; ///< calibration
PathPlanning *path; ///< path-planning
Strategy *strat; ///< strategy
int main_state; ///< main state
int robot_id;   ///< ID of the robot
int team_id;    ///< ID of the team
};

或者

typedef struct CtrlStruct{
CtrlIn *inputs;   ///< controller inputs
CtrlOut *outputs; ///< controller outputs
RobotPosition *rob_pos; ///< robot position
OpponentsPosition *opp_pos; ///< opponents position
SpeedRegulation *sp_reg; ///< speed regulation
RobotCalibration *calib; ///< calibration
PathPlanning *path; ///< path-planning
Strategy *strat; ///< strategy
int main_state; ///< main state
int robot_id;   ///< ID of the robot
int team_id;    ///< ID of the team
}ctrlStruct;