Skip to content
Matthew Woehlke edited this page Jun 17, 2018 · 2 revisions
  • Uncrustify currently does not keep track of braces that span multiple preprocessor blocks and therefore will abort and complain about missing braces in code like the example below:

    #if(1)
      if(true)
      {
    #endif
        int i = 1;
    #if(1)
      }
    #endif

    If you want to use Uncrustify on your code, avoid this kind of brace placement until this problem is fixed.

  • C++ is a notoriously hard to parse language as its grammar is ambiguous, context-dependent and potentially requires infinite lookahead to resolve some ambiguities.

    Currently Uncrustify's parser is not well equipped to handle such edge cases well. This construct, for example, is problematic:

        A b(c*d);

    The above example could either be:

    • A declaration of a function b with A as return type, c* as a parameter type, and d as the parameter name

      or

    • A declaration of a variable b of type A, with a constructor call with the parameter of variable c multiplied by variable d

    To remove the ambiguity in the above example, parenthesis can be added around c so that the construct will be parsed as a variable declaration.

        A b((c)*d);
Clone this wiki locally