Closed homui closed 5 months ago
能举个例子吗
你好,我遇到一个问题 执行 cxx2flow --cpp -c src/auto.cpp autonomous_driving_decision 报错: 20 errors generated. Error: cxx2flow::target_function_not_found
× target function not found ╭──── 1 │ autonomous_driving_decision · ─────────────┬───────────── · ╰── this is the name of your target function ╰──── help: maybe you have a typo, or source code is incomplete, please check your input
源文件:
// 定义车辆状态枚举类型 typedef enum { NORMAL, EMERGENCY_BRAKE, MAINTAIN_SPEED, SLOW_DOWN, STOP } VehicleState;
// 定义传感器输入结构体 typedef struct { int obstacle_distance; // 障碍物距离(单位:米) int speed; // 车速(单位:千米/小时) bool is_traffic_light_green; // 交通灯状态(true表示绿灯,false表示红灯) bool is_pedestrian_nearby; // 附近是否有行人 } SensorInput;
// 自动驾驶行为决策函数 VehicleState autonomous_driving_decision(SensorInput sensor_data) { if (sensor_data.obstacle_distance < 0 || sensor_data.speed < 0) { printf("Error: Invalid sensor data.\n"); return STOP; }
if (sensor_data.is_traffic_light_green)
{
if (sensor_data.obstacle_distance > 50 && sensor_data.speed > 60)
{
return MAINTAIN_SPEED;
}
else if (sensor_data.obstacle_distance <= 50 && sensor_data.speed > 40)
{
return SLOW_DOWN;
}
else
{
if (sensor_data.is_pedestrian_nearby &&
sensor_data.obstacle_distance > 10)
{
return SLOW_DOWN;
}
else
{
return NORMAL;
}
}
}
else
{
if (sensor_data.obstacle_distance > 30 && sensor_data.speed > 30)
{
return MAINTAIN_SPEED;
}
else if (sensor_data.obstacle_distance <= 10)
{
return EMERGENCY_BRAKE;
}
else
{
if (sensor_data.is_pedestrian_nearby &&
sensor_data.obstacle_distance > 20)
{
return EMERGENCY_BRAKE;
}
else
{
return NORMAL;
}
}
}
}
比如流程图里只包含if else这些分支选项