C++ code generated by protoc (protobuf compiler) can lead to parsing errors when generating C++ code or config with plcncli using one of the following commands:
plcncli generate code
plcncli generate config
plcncli generate all
Error looks like this:
exchange.pb.h(407,0): error CPP0005: A parsing exception was thrown.
parsing exception occured while parsing 'brace_group' expected '(skip([}]) + skip(multiline_ws*))' at line number 407, and character number 0
A fix has been documented on the PLCNext Community forum (here).
You have to move all your protoc generated C++ files from src to another directory. For example, rpc/. To include these files during compilation, you have to update the CMakeLists.txtconfiguration. For example, if we moved the files to a rpc/ folder like mentioned earlier, it can be done like this:
################# create target #######################################################
file(GLOB_RECURSE Headers CONFIGURE_DEPENDS src/*.h src/*.hpp src/*.hxx intermediate/code/*.h intermediate/code/*.hpp intermediate/code/*.hxx rpc/*.h)
file(GLOB_RECURSE Sources CONFIGURE_DEPENDS src/*.cpp src/*.cc intermediate/code/*.cpp rpc/*.cc)
add_library(${CMAKE_PROJECT_NAME} SHARED ${Headers} ${Sources})
#######################################################################################
################# project include-paths ###############################################
target_include_directories(${CMAKE_PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/intermediate/code>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/rpc>)
#######################################################################################
Alternatively, you can generate code/config files with plcncli before generating code with protoc. For instance, this fix can be used if the project is compiled with a script:
#!bin/bash
plcncli generate all
protoc --cpp_out=./ file.proto
plcncli build
C++ code generated by protoc (protobuf compiler) can lead to parsing errors when generating C++ code or config with plcncli using one of the following commands:
Error looks like this:
A fix has been documented on the PLCNext Community forum (here).
You have to move all your
protocgenerated C++ files fromsrcto another directory. For example,rpc/. To include these files during compilation, you have to update theCMakeLists.txtconfiguration. For example, if we moved the files to arpc/folder like mentioned earlier, it can be done like this:Alternatively, you can generate code/config files with plcncli before generating code with protoc. For instance, this fix can be used if the project is compiled with a script: