I spontaneosly wonder if you could have a preprocessing problem. If I copy/paste your code here I do not get this warning. If I comment out the define then the warning is shown. Does the warning go away if you replace DIFF_UART_MSG_SIZE with (12U) in your code?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes the warning does go away. But cppcheck doesn't use the preprocessor, correct? I can compile just find, my preprocessor is finding DIFF_UART_MSG_SIZE. But cppcheck doesn't seem to be finding it?
Looks like cppcheck was not finding the header files. I've added the -I option for all the places to look for the .h files and it works now. Thanks for the help!
I'm curious, does the -I option search recursively through sub-directories?
Regards,
Amir
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've added the -I option for all the places to look for the .h files and it works now.
Great!
I'm curious, does the -I option search recursively through sub-directories?
No. We have talked about such behavior. It would be convenient. Well the problem is if you include "foo.h" and there are both "path1/foo.h" and "path2/foo.h".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Good point, thanks for all the help, cppcheck has proven to be much easier to use than other paid options I've looked at for MISRA. Donation coming your way.
EDIT: How can I donate to your project?
Last edit: Amir 2020-05-28
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I believe the best options are either:
* You can sponsor cppcheck contributors. Me: http://github.com/danmar , not sure if anybody else has that option.
* You can sponsor future kickstarter projects. Do you want that I send you email when I create a Kickstarter project?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I'm getting a false positive on rule 18.8. Here is what I'm seeing:
ealPcuComm.c:
mcalUartApi.h:
#define DIFF_UART_MSG_SIZE (12U)
I'm getting a false positive on:
uint8_t sendMsg[DIFF_UART_MSG_SIZE] = {'\0'};
Error:
eal\ealPcuComm.c:53:10: style: Required. Variable-length array types shall not be used [misra-c2012-18.8]
Last edit: Amir 2020-05-26
I spontaneosly wonder if you could have a preprocessing problem. If I copy/paste your code here I do not get this warning. If I comment out the define then the warning is shown. Does the warning go away if you replace
DIFF_UART_MSG_SIZE
with(12U)
in your code?Yes the warning does go away. But cppcheck doesn't use the preprocessor, correct? I can compile just find, my preprocessor is finding DIFF_UART_MSG_SIZE. But cppcheck doesn't seem to be finding it?
Here is misra.json:
Here is cppcheck command I'm using:
cppcheck -rp --inline-suppr --addon=..\cppcheck\misra.json ..\Sources -I ..\BCC
Regards,
Amir
cppcheck preprocess the code. does it show some related warnings if you run:
cppcheck --check-config ..\Sources -I..\BCC
.Hi Daniel,
Looks like cppcheck was not finding the header files. I've added the -I option for all the places to look for the .h files and it works now. Thanks for the help!
I'm curious, does the -I option search recursively through sub-directories?
Regards,
Amir
Great!
No. We have talked about such behavior. It would be convenient. Well the problem is if you include "foo.h" and there are both "path1/foo.h" and "path2/foo.h".
Good point, thanks for all the help, cppcheck has proven to be much easier to use than other paid options I've looked at for MISRA. Donation coming your way.
EDIT: How can I donate to your project?
Last edit: Amir 2020-05-28
I believe the best options are either:
* You can sponsor cppcheck contributors. Me: http://github.com/danmar , not sure if anybody else has that option.
* You can sponsor future kickstarter projects. Do you want that I send you email when I create a Kickstarter project?