Open oliverbl opened 5 years ago
Hello, I'm facing exactly the same issue. Any help would be welcomed.
I am also having this issue, any advice?
I have created a small example to reproduce it quickly mock_fail_func_sig.zip
vendor/ceedling/vendor/cmock/lib/cmock_header_parser.rb around line 225:
arg_list.gsub!(/(\w+)(?:\s*\[\s*\(*[\s\d\w+-]*\)*\s*\])+/,'*\1') # magically turn brackets into asterisks, also match for parentheses that come from macros
so here's how you can "fix"/hack it for now:
first of all I replaced that line from my previous comment with like 6 of these lines.
arg_list.gsub!(/(\w+)(?:\s*\[\s*\(*[\s\d\w+-]*\)*\s*\])/,'*\1')
If you note, the "+" is missing in my version. I removed it so it doesn't replace all brackets, it just replaces one bracket at the time with one "*" for each
replacing it with 6 lines probably fails if you use more than 6 sets of brackets in one argument. maybe some maintainer can implement this better?
also, in the cmock_header_parser.rb around line 270 or so in function parse_declaration(declaration), after the "if else end" part where it says "#check for var args", I added a line:
decl[:original_args] = args.dup
before the call to "clean_args". That way I have the original argument saved.
Then in cmock_generator.rb on line 229 in function create_mock_implementation I replaced
#args_string = function[:args_string]
args_string = function[:original_args]
that way the generated .c mock file has the original args and the .h uses the **
if you feel bold you may apply this patch:
from your project root:
patch -s -p0 < function_signatures.txt
the regex is making me nauseous.
arg_list.gsub!(/(\w+)(?:\s*\[\s*\(*[\s\d\w+-]*\)*\s*\])/,'*\1')
Somebody please fix it, for the love of science!
I forgot to mention, it caused problems when generating *.c files where the argument contained enums. for now I fixed it for me like this:
if function[:original_args].index("[") != nil
args_string = function[:original_args]
else
args_string = function[:args_string]
end
I forgot to mention, it caused problems when generating *.c files where the argument contained enums. for now I fixed it for me like this:
if function[:original_args].index("[") != nil
args_string = function[:original_args]
else
args_string = function[:args_string]
end
In which file did you change this? Thanks for your fix
Edit: Oh wait, I got it..
This issue affects me building Ceedling unit tests with GCC compiler version 11.2.0 on Linux. To suppress the build warning, I have added the following compiler flag for unit test builds:
Wno-array-parameter
Is this feature a candidate for ceedling 0.32? It would be helpful to avoid suppressing gcc warnings, unless absolutely necessary.
Hi, I'm running into this issue. Is there a recommended work around or fix at this point? Is the best current solution what @alex116 shared? Thanks!
I have some functions which are like the following:
void foo(uint8_t data[PARAM_1][PARAM_2]);
now cmock will generate the following mock function for it:
void foo(uint8_t *data);
This causes an error while compiling:
So at the moment I cant use cmock
Im using gcc 4.8.3 as the compiler