I'm trying to find all the places we have ambiguous format specifiers in our code base.
For example:
int64_t fixed_size_type;
printf ("Ambiguous replacement value: %lld", fixed_size_type);
Which results in:
format '%lld' expects argument of type 'long long int', but argument 5 has type 'int64_t {aka long int}' [-Wformat=]
I'm using regex to search the code base, and I want to find all occurrences of %lld
where the values have NOT been cast into (long long)
.
Using the VSCode search tab, I can find all appropriately cast occurrences using:
%lld.*(\(long long\))
However, I don't know how to ask it to show me the strings where (long long)
in not present?
When I try:
%lld(?!.*\(long long\))
VSCode gives me the following error message:
Error parsing regex near 'lld(?!.*\(' at character offset 6: Unrecognized flag: '!'. (Allowed flags: i, m, s, U, u, x.)
I have tried several examples I have seen in forums with similar problems, and I have tried to use regex documentation to cipher those examples; all with no avail.
Most examples suggest you use a negative lookahead or lookbehind to check for the existence of the (long long)
substring. I thought parenthesis made a block. Why we can't use I just negate a block with forward logic.
Unfortunately, regex processing and syntax is difficult to comprehend when you have so little working experience with regex.
NOTE: The duplicate suggestion offers a great explanation of why this doesn't work in VSCode, but it still doesn't provide the solution to my question.