We ran into a problem where when calling mcpp as a library function multiple times sometimes caused it to not emit the first #line directive in the output. I was able to determine the cause of this bug. It is because of the fact that sh_file and sh_line are declared as static variables in the sharp() function in system.c, but do not get reset when mcpp_lib_main() is called multiple times.
The solution to the problem is to make them global variables instead and then initialize them in init_main()
sh_file = NULL
sh_line = 0
Please incorporate this change into the next release of mcpp. Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
We ran into a problem where when calling mcpp as a library function multiple times sometimes caused it to not emit the first #line directive in the output. I was able to determine the cause of this bug. It is because of the fact that sh_file and sh_line are declared as static variables in the sharp() function in system.c, but do not get reset when mcpp_lib_main() is called multiple times.
The solution to the problem is to make them global variables instead and then initialize them in init_main()
sh_file = NULL
sh_line = 0
Please incorporate this change into the next release of mcpp. Thanks.