我想一些代码由C转换为C++ 这是一个用带摄像头模块树莓派一个项目,我想分析的图片吧。从C代码转换到C++
但在这一段代码(别人创建)我得到这个错误
231:8: error: expected primary-expression before ‘.’ token
这是这一行:
.max_stills_w = state->width,
我尝试了所有我能找到,但它一直给我其他错误
video_port = camera->output[MMAL_CAMERA_VIDEO_PORT];
still_port = camera->output[MMAL_CAMERA_CAPTURE_PORT];
// set up the camera configuration
{
MMAL_PARAMETER_CAMERA_CONFIG_T cam_config =
{
{ MMAL_PARAMETER_CAMERA_CONFIG, sizeof(cam_config) },
.max_stills_w = state->width,
.max_stills_h = state->height,
.stills_yuv422 = 0,
.one_shot_stills = 0,
.max_preview_video_w = state->width,
.max_preview_video_h = state->height,
.num_preview_video_frames = 3,
.stills_capture_circular_buffer_height = 0,
.fast_preview_resume = 0,
.use_stc_timestamp = MMAL_PARAM_TIMESTAMP_MODE_RESET_STC
};
mmal_port_parameter_set(camera->control, &cam_config.hdr);
}
// Set the encode format on the video port
这是一个C99功能,不可用C++编写。你只需实例化你的'struct'变量,然后赋值给指定的成员,你不能用写成的名字成员来初始化。 – CoryKramer
@Cyber这个问题是否解释了如何在C++中进行等价处理?如果不是,它不是重复的。 – Barmar
您不应该转换工作的C代码。我建议用C++包装C代码(如果它有开发/维护的好处) –