Menu

#142 "macro names must be identifers" error when defining non-ASCII macro

open
nobody
None
5
2021-04-07
2021-04-07
Wu Xuan
No

Hi, thanks for adding non-ASCII identifiers support in 4.0, and it does work:
ok

However, when defining a macro with unicode naming, it gives compile error: "macro names must be identifers"
error

We wonder if there's any workaround?

Thanks.

Discussion

  • Philipp Klaus Krause

    This is a limitation of the preprocessor SDCC uses, which is based on GNU cpp 4.6.3.
    I don't think it would be worth the effort to fix this in the current preprocessor: For ISO C23 support we need to replace the preprocessor anyway (possibly by one based on GNU cpp 10), which I hope we'll get around to do next winter. See [feature-requests:#466]
    That would then give us support for non-ASCII characters in macros.

    There is a workaround (that I've never used myself), but unless your editor support automatic conversion to escape sequences it might not be what you want: By passing -fextended-identifiers to the preprocessor, non-ASCII characters should work via \u and \U escape sequences.

     

    Related

    Feature Requests: #466


    Last edit: Maarten Brock 2021-05-24
  • Benedikt Freisen

    Depending on the exact context, chances are that you can use C constants instead of preprocessor defines.

     

Log in to post a comment.